module Sequel::Plugins::ModificationDetection::InstanceMethods
Public Instance Methods
Source
# File lib/sequel/plugins/modification_detection.rb 48 def after_update 49 super 50 recalculate_values_hashes 51 end
Recalculate the column value hashes after updating.
Calls superclass method
Source
# File lib/sequel/plugins/modification_detection.rb 54 def calculate_values_hashes 55 @values_hashes || recalculate_values_hashes 56 end
Calculate the column hash values if they haven’t been already calculated.
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
Detect which columns have been modified by comparing the cached hash value to the hash of the current value.
Calls superclass method
Private Instance Methods
Source
# File lib/sequel/plugins/modification_detection.rb 80 def _refresh(dataset) 81 super 82 recalculate_values_hashes 83 end
Recalculate the column value hashes after manually refreshing.
Calls superclass method
Source
# File lib/sequel/plugins/modification_detection.rb 86 def _save_refresh 87 super 88 recalculate_values_hashes 89 end
Recalculate the column value hashes after refreshing after saving a new object.
Calls superclass method
Source
# File lib/sequel/plugins/modification_detection.rb 92 def recalculate_values_hashes 93 vh = {} 94 @values.each do |k,v| 95 vh[k] = v.hash 96 end 97 @values_hashes = vh.freeze 98 end
Recalculate the column value hashes, caching them for later use.