Module Mongoid::Fields::Serializable::Timekeeping
In: lib/mongoid/fields/serializable/timekeeping.rb

This module contains shared behaviour for date conversions.

Methods

Public Instance methods

When reading the field do we need to cast the value? This holds true when times are stored or for big decimals which are stored as strings.

@example Typecast on a read?

  field.cast_on_read?

@return [ true ] Date fields cast on read.

@since 2.1.0

Convert the provided object to a UTC time to store in the database.

@example Set the time.

  Time.convert_to_time(Date.today)

@param [ String, Date, DateTime, Array ] value The object to cast.

@return [ Time ] The object as a UTC time.

@since 1.0.0

Deserialize this field from the type stored in MongoDB to the type defined on the model.

@example Deserialize the field.

  field.deserialize(object)

@param [ Object ] object The object to cast.

@return [ Time ] The converted time.

@since 2.1.0

Serialize the object from the type defined in the model to a MongoDB compatible object to store.

@example Serialize the field.

  field.serialize(object)

@param [ Object ] object The object to cast.

@return [ Time ] The converted UTC time.

@since 2.1.0

Strip the milliseconds off the time.

@todo Durran: Why is this here? Still need time refactoring.

@example Strip.

  Time.strip_millseconds(Time.now)

@param [ Time ] time The time to strip.

@return [ Time ] The time without millis.

@since 2.1.0

[Validate]