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
50 def after_update
51   super
52   recalculate_values_hashes
53 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
56 def calculate_values_hashes
57   @values_hashes || recalculate_values_hashes
58 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
62 def changed_columns
63   changed = super
64   if vh = @values_hashes
65     values = @values
66     changed = changed.dup if frozen?
67     vh.each do |c, v|
68       match = values.has_key?(c) && v == values[c].hash
69       if changed.include?(c)
70         changed.delete(c) if match
71       else
72         changed << c unless match
73       end
74     end
75   end
76   changed
77 end