Sha256: 9f3105e01a478392b173a1399622a0e09e71a59a9dfae01d1872f8e0afea372c

Contents?: true

Size: 330 Bytes

Versions: 4

Compression:

Stored size: 330 Bytes

Contents

require 'active_support/core_ext/time/conversions'
require 'active_support/core_ext/string/conversions'

module MongoModel
  module Types
    class Time < Object
      def cast(value)
        time = value.to_time
        time.change(:usec => (time.usec / 1000.0).floor * 1000)
      rescue
        nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongomodel-0.2.10 lib/mongomodel/support/types/time.rb
mongomodel-0.2.9 lib/mongomodel/support/types/time.rb
mongomodel-0.2.8 lib/mongomodel/support/types/time.rb
mongomodel-0.2.7 lib/mongomodel/support/types/time.rb