module Sequel::Plugins::ModificationDetection::InstanceMethods
Public Instance Methods
after_update()
click to toggle source
Recalculate the column value hashes after updating.
Calls superclass method
# File lib/sequel/plugins/modification_detection.rb, line 48 def after_update super recalculate_values_hashes end
calculate_values_hashes()
click to toggle source
Calculate the column hash values if they haven't been already calculated.
# File lib/sequel/plugins/modification_detection.rb, line 54 def calculate_values_hashes @values_hashes || recalculate_values_hashes end
changed_columns()
click to toggle source
Detect which columns have been modified by comparing the cached hash value to the hash of the current value.
Calls superclass method
# File lib/sequel/plugins/modification_detection.rb, line 60 def changed_columns changed = super if vh = @values_hashes values = @values changed = changed.dup if frozen? vh.each do |c, v| match = values.has_key?(c) && v == values[c].hash if changed.include?(c) changed.delete(c) if match else changed << c unless match end end end changed end
Private Instance Methods
_refresh(dataset)
click to toggle source
Recalculate the column value hashes after manually refreshing.
Calls superclass method
# File lib/sequel/plugins/modification_detection.rb, line 80 def _refresh(dataset) super recalculate_values_hashes end
_save_refresh()
click to toggle source
Recalculate the column value hashes after refreshing after saving a new object.
Calls superclass method
# File lib/sequel/plugins/modification_detection.rb, line 86 def _save_refresh super recalculate_values_hashes end
recalculate_values_hashes()
click to toggle source
Recalculate the column value hashes, caching them for later use.
# File lib/sequel/plugins/modification_detection.rb, line 92 def recalculate_values_hashes vh = {} @values.each do |k,v| vh[k] = v.hash end @values_hashes = vh.freeze end