Parent

DataMapper::Property::EpochTime

Public Instance Methods

custom?() click to toggle source
# File lib/dm-types/epoch_time.rb, line 19
def custom?
  true
end
dump(value) click to toggle source
# File lib/dm-types/epoch_time.rb, line 15
def dump(value)
  value.to_i if value
end
load(value) click to toggle source
# File lib/dm-types/epoch_time.rb, line 7
def load(value)
  if value.kind_of?(::Numeric)
    ::Time.at(value.to_i)
  else
    value
  end
end
typecast(value) click to toggle source
# File lib/dm-types/epoch_time.rb, line 23
def typecast(value)
  case value
    when ::Time               then value
    when ::Numeric, /\A\d+\z/ then ::Time.at(value.to_i)
    when ::DateTime           then datetime_to_time(value)
    when ::String             then ::Time.parse(value)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.