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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deserialized_valuesObject (readonly)

Hash of deserialized values, used as a cache.


96
97
98
# File 'lib/sequel/lib/sequel/plugins/serialization.rb', line 96

def deserialized_values
  @deserialized_values
end

Instance Method Details

#before_saveObject

Serialize all deserialized values


105
106
107
108
109
110
# File 'lib/sequel/lib/sequel/plugins/serialization.rb', line 105

def before_save
  super
  deserialized_values.each do |k,v|
    @values[k] = serialize_value(k, v)
  end
end

#initialize(*args, &block) ⇒ Object

Set @deserialized_values to the empty hash


99
100
101
102
# File 'lib/sequel/lib/sequel/plugins/serialization.rb', line 99

def initialize(*args, &block)
  @deserialized_values = {}
  super
end

#refreshObject

Empty the deserialized values when refreshing.


113
114
115
116
# File 'lib/sequel/lib/sequel/plugins/serialization.rb', line 113

def refresh
  @deserialized_values = {}
  super
end