Sha256: 677b1c81df4031db6d51769ce6c005089e454eb3e34aea98c87e0f8a1a6ca358

Contents?: true

Size: 408 Bytes

Versions: 17

Compression:

Stored size: 408 Bytes

Contents

require 'active_support/core_ext/date/conversions'
require 'active_support/core_ext/string/conversions'

module MongoModel
  module Types
    class Date < Object
      def cast(value)
        value.to_date rescue nil
      end
      
      def to_mongo(value)
        value.strftime("%Y/%m/%d") if value
      end
      
      def from_mongo(value)
        value.to_date if value
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mongomodel-0.2.10 lib/mongomodel/support/types/date.rb
mongomodel-0.2.9 lib/mongomodel/support/types/date.rb
mongomodel-0.2.8 lib/mongomodel/support/types/date.rb
mongomodel-0.2.7 lib/mongomodel/support/types/date.rb
mongomodel-0.2.6 lib/mongomodel/support/types/date.rb
mongomodel-0.2.5 lib/mongomodel/support/types/date.rb
mongomodel-0.2.4 lib/mongomodel/support/types/date.rb
mongomodel-0.2.3 lib/mongomodel/support/types/date.rb
mongomodel-0.2.2 lib/mongomodel/support/types/date.rb
mongomodel-0.2.1 lib/mongomodel/support/types/date.rb
mongomodel-0.2.0 lib/mongomodel/support/types/date.rb
mongomodel-0.1.6 lib/mongomodel/support/types/date.rb
mongomodel-0.1.5 lib/mongomodel/support/types/date.rb
mongomodel-0.1.4 lib/mongomodel/support/types/date.rb
mongomodel-0.1.3 lib/mongomodel/support/types/date.rb
mongomodel-0.1.1 lib/mongomodel/support/types/date.rb
mongomodel-0.1 lib/mongomodel/support/types/date.rb