class Tod::TimeOfDayType

Public Instance Methods

cast(value) click to toggle source
# File lib/tod/time_of_day_type.rb, line 3
def cast(value)
  if value.is_a? Hash
      # rails multiparam attribute
      # get hour, minute and second and construct new TimeOfDay object
    ::Tod::TimeOfDay.new(value[4], value[5], value[6])
  else
    # return nil, if input is not parsable
    Tod::TimeOfDay(value){}
  end
end
serialize(value) click to toggle source
# File lib/tod/time_of_day_type.rb, line 14
def serialize(value)
  value.to_s if value.present?
end