Module: Sequel::Plugins::SerializationModificationDetection::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#after_saveObject

Clear the cache of original deserialized values after saving so that it doesn't show the column is modified after saving.


37
38
39
40
# File 'lib/sequel/plugins/serialization_modification_detection.rb', line 37

def after_save
  super
  @original_deserialized_values = @deserialized_values
end

#changed_columnsObject

Detect which serialized columns have changed.


43
44
45
46
47
48
# File 'lib/sequel/plugins/serialization_modification_detection.rb', line 43

def changed_columns
  cc = super
  cc = cc.dup if frozen?
  deserialized_values.each{|c, v| cc << c if !cc.include?(c) && original_deserialized_value(c) != v} 
  cc
end

#freezeObject

Freeze the original deserialized values when freezing the instance.


51
52
53
54
55
# File 'lib/sequel/plugins/serialization_modification_detection.rb', line 51

def freeze
  @original_deserialized_values ||= {}
  @original_deserialized_values.freeze
  super
end