module Sequel::Plugins::ModificationDetection::InstanceMethods

  1. lib/sequel/plugins/modification_detection.rb

Public Instance methods

after_update()

Recalculate the column value hashes after updating.

[show source]
   # File lib/sequel/plugins/modification_detection.rb
48 def after_update
49   super
50   recalculate_values_hashes
51 end
calculate_values_hashes()

Calculate the column hash values if they haven’t been already calculated.

[show source]
   # File lib/sequel/plugins/modification_detection.rb
54 def calculate_values_hashes
55   @values_hashes || recalculate_values_hashes
56 end
changed_columns()

Detect which columns have been modified by comparing the cached hash value to the hash of the current value.

[show source]
   # File lib/sequel/plugins/modification_detection.rb
60 def changed_columns
61   changed = super
62   if vh = @values_hashes
63     values = @values
64     changed = changed.dup if frozen?
65     vh.each do |c, v|
66       match = values.has_key?(c) && v == values[c].hash
67       if changed.include?(c)
68         changed.delete(c) if match
69       else
70         changed << c unless match
71       end
72     end
73   end
74   changed
75 end