Module | Sequel::Plugins::ModificationDetection::InstanceMethods |
In: |
lib/sequel/plugins/modification_detection.rb
|
Recalculate the column value hashes after updating.
# File lib/sequel/plugins/modification_detection.rb, line 45 45: def after_update 46: super 47: recalculate_values_hashes 48: end
Calculate the column hash values if they haven‘t been already calculated.
# File lib/sequel/plugins/modification_detection.rb, line 51 51: def calculate_values_hashes 52: @values_hashes || recalculate_values_hashes 53: end
Detect which columns have been modified by comparing the cached hash value to the hash of the current value.
# File lib/sequel/plugins/modification_detection.rb, line 57 57: def changed_columns 58: cc = super 59: changed = [] 60: v = @values 61: if vh = @values_hashes 62: (vh.keys - cc).each{|c| changed << c unless v.has_key?(c) && vh[c] == v[c].hash} 63: end 64: cc + changed 65: end