module SerializedAttributes::InstanceMethods
Public Instance Methods
create_or_update()
click to toggle source
Calls superclass method
# File lib/serialized_attributes.rb, line 47 def create_or_update pack_serialized_attributes! super end
pack_serialized_attributes!()
click to toggle source
# File lib/serialized_attributes.rb, line 62 def pack_serialized_attributes! if @attributes.has_key?(serialized_attributes_column.to_s) attributes = self[serialized_attributes_column] ||= {} serialized_attributes_definition.each do |key, column| attributes[key] = self.send key end end attributes.slice!(*serialized_attributes_definition.keys) end
unpack_serialized_attributes!()
click to toggle source
# File lib/serialized_attributes.rb, line 52 def unpack_serialized_attributes! if @attributes.has_key?(serialized_attributes_column.to_s) && attributes = (self[serialized_attributes_column] || {}) serialized_attributes_definition.each do |key, column| loaded_value = attributes.has_key?(key) ? attributes[key] : column.default @attributes[key] = attributes.has_key?(key) ? attributes[key] : column.default end attributes.slice!(*serialized_attributes_definition.keys) end end