Module: Sequel::Plugins::Serialization::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#before_saveObject

Serialize deserialized values before saving



165
166
167
168
# File 'lib/sequel/plugins/serialization.rb', line 165

def before_save
  serialize_deserialized_values
  super
end

#deserialized_valuesObject

Hash of deserialized values, used as a cache.



171
172
173
# File 'lib/sequel/plugins/serialization.rb', line 171

def deserialized_values
  @deserialized_values ||= {}
end

#freezeObject



175
176
177
178
# File 'lib/sequel/plugins/serialization.rb', line 175

def freeze
  deserialized_values.freeze
  super
end

#set_values(hash) ⇒ Object

Initialization the deserialized values for objects retrieved from the database.



181
182
183
184
# File 'lib/sequel/plugins/serialization.rb', line 181

def set_values(hash)
  @deserialized_values.clear if @deserialized_values
  super
end