Module: Sequel::Plugins::TypecastOnLoad::InstanceMethods

Defined in:
lib/sequel/plugins/typecast_on_load.rb

Instance Method Summary collapse

Instance Method Details

#load_typecastObject

Call the setter method for each of the model’s typecast_on_load_columns with the current value, so it can be typecasted correctly.



45
46
47
48
49
50
51
52
53
# File 'lib/sequel/plugins/typecast_on_load.rb', line 45

def load_typecast
  model.typecast_on_load_columns.each do |c|
    if v = values[c]
      send("#{c}=", v)
    end
  end
  changed_columns.clear
  self
end

#set_values(values) ⇒ Object

Typecast values using #load_typecast when the values are retrieved from the database.



57
58
59
60
61
# File 'lib/sequel/plugins/typecast_on_load.rb', line 57

def set_values(values)
  ret = super
  load_typecast
  ret
end