Parent

DataMapper::Property::EpochTime

Public Instance Methods

custom?() click to toggle source
    # File lib/dm-types/epoch_time.rb, line 19
19:       def custom?
20:         true
21:       end
dump(value) click to toggle source
    # File lib/dm-types/epoch_time.rb, line 15
15:       def dump(value)
16:         value.to_i if value
17:       end
load(value) click to toggle source
    # File lib/dm-types/epoch_time.rb, line 7
 7:       def load(value)
 8:         if value.kind_of?(::Numeric)
 9:           ::Time.at(value.to_i)
10:         else
11:           value
12:         end
13:       end
typecast(value) click to toggle source
    # File lib/dm-types/epoch_time.rb, line 23
23:       def typecast(value)
24:         case value
25:           when ::Time               then value
26:           when ::Numeric, /\A\d+\z/ then ::Time.at(value.to_i)
27:           when ::DateTime           then datetime_to_time(value)
28:           when ::String             then ::Time.parse(value)
29:         end
30:       end

Private Instance Methods

datetime_to_time(datetime) click to toggle source
    # File lib/dm-types/epoch_time.rb, line 34
34:       def datetime_to_time(datetime)
35:         utc = datetime.new_offset(0)
36:         ::Time.utc(utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec)
37:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.