Class: DataMapper::Types::EpochTime

Public Visibility

Public Class Method Summary

dump(value, property)
load(value, property)

Public Class Methods Inherited from DataMapper::Type

bind, configure, inherited, options, primitive

Public Instance Methods Inherited from Object

validatable?

Public Class Method Details

dump

public dump(value, property)
[View source]


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'dm-more/dm-types/lib/dm-types/epoch_time.rb', line 15

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

load

public load(value, property)
[View source]


6
7
8
9
10
11
12
13
14
15
16
17
# File 'dm-more/dm-types/lib/dm-types/epoch_time.rb', line 6

def self.load(value, property)
  case value




  when Integer
    Time.at(value)
  else
    value
  end
end