Module: Sequel::Plugins::ModificationDetection::InstanceMethods

Defined in:
lib/sequel/plugins/modification_detection.rb

Instance Method Summary collapse

Instance Method Details

#after_updateObject

Recalculate the column value hashes after updating.



45
46
47
48
# File 'lib/sequel/plugins/modification_detection.rb', line 45

def after_update
  super
  recalculate_values_hashes
end

#calculate_values_hashesObject

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



51
52
53
# File 'lib/sequel/plugins/modification_detection.rb', line 51

def calculate_values_hashes
  @values_hashes || recalculate_values_hashes
end

#changed_columnsObject

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



57
58
59
60
61
62
63
64
65
# File 'lib/sequel/plugins/modification_detection.rb', line 57

def changed_columns
  cc = super
  changed = []
  v = @values
  if vh = @values_hashes
    (vh.keys - cc).each{|c| changed << c unless v.has_key?(c) && vh[c] == v[c].hash}
  end
  cc + changed
end