Class: Mongoid::Fields::Internal::DateTime

Inherits:
Object
  • Object
show all
Includes:
Timekeeping, Serializable
Defined in:
lib/mongoid/fields/internal/date_time.rb

Overview

Defines the behaviour for date time fields.

Instance Attribute Summary

Attributes included from Serializable

#default_val, #label, #localize, #name, #options

Instance Method Summary collapse

Methods included from Timekeeping

#cast_on_read?, #convert_to_time, #selection, #serialize, #strip_milliseconds

Methods included from Serializable

#constraint, #eval_default, #foreign_key?, #localized?, #metadata, #object_id_field?, #resizable?, #selection, #serialize, #type, #versioned?

Instance Method Details

#deserialize(object) ⇒ DateTime

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

Examples:

Deserialize the field.

field.deserialize(object)

Parameters:

  • object (Object)

    The object to cast.

Returns:

  • (DateTime)

    The converted date time.

Since:

  • 2.1.0



22
23
24
# File 'lib/mongoid/fields/internal/date_time.rb', line 22

def deserialize(object)
  super(object).try(:to_datetime)
end