Sha256: aefd42643ea57e47595ef9e4c24e963f170e85a9b79aaec669897e83f27f476d

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Fields #:nodoc:
    module Internal #:nodoc:

      # Defines the behaviour for date time fields.
      class DateTime
        include Serializable
        include Timekeeping

        # 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 [ DateTime ] The converted date time.
        #
        # @since 2.1.0
        def deserialize(object)
          object.try(:to_datetime)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-2.4.2 lib/mongoid/fields/internal/date_time.rb
mongoid-2.4.1 lib/mongoid/fields/internal/date_time.rb
mongoid-2.4.0 lib/mongoid/fields/internal/date_time.rb