Sha256: b9669cb9bd540f85133a6d98cc39f8b0ee7dc10a1afd52b1354cf35c1cd1782d

Contents?: true

Size: 539 Bytes

Versions: 13

Compression:

Stored size: 539 Bytes

Contents

module DataMapper
  module Types
    class EpochTime < DataMapper::Type
      primitive Integer

      def self.load(value, property)
        case value
        when Integer
          Time.at(value)
        else
          value
        end
      end

      def self.dump(value, property)
        case value
        when Integer
          value
        when Time
          value.to_i
        when DateTime
          Time.parse(value.to_s).to_i
        end
      end
    end # class EpochTime
  end # module Types
end # module DataMapper

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
dm-types-0.9.3 lib/dm-types/epoch_time.rb
dm-types-0.9.10 lib/dm-types/epoch_time.rb
dm-types-0.9.5 lib/dm-types/epoch_time.rb
dm-types-0.9.2 lib/dm-types/epoch_time.rb
dm-types-0.9.11 lib/dm-types/epoch_time.rb
dm-types-0.9.4 lib/dm-types/epoch_time.rb
dm-types-0.9.6 lib/dm-types/epoch_time.rb
dm-types-0.9.9 lib/dm-types/epoch_time.rb
dm-types-0.9.8 lib/dm-types/epoch_time.rb
dm-types-0.9.7 lib/dm-types/epoch_time.rb
mack-data_mapper-0.8.2 lib/gems/dm-types-0.9.7/lib/dm-types/epoch_time.rb
mack-data_mapper-0.8.3 lib/gems/dm-types-0.9.9/lib/dm-types/epoch_time.rb
mack-data_mapper-0.8.3.1 lib/gems/dm-types-0.9.9/lib/dm-types/epoch_time.rb