Module Sequel::Plugins::ModificationDetection::InstanceMethods
In: lib/sequel/plugins/modification_detection.rb

Methods

Public Instance methods

Recalculate the column value hashes after updating.

[Source]

    # File lib/sequel/plugins/modification_detection.rb, line 48
48:         def after_update
49:           super
50:           recalculate_values_hashes
51:         end

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

[Source]

    # File lib/sequel/plugins/modification_detection.rb, line 54
54:         def calculate_values_hashes
55:           @values_hashes || recalculate_values_hashes
56:         end

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

[Source]

    # File lib/sequel/plugins/modification_detection.rb, line 60
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

[Validate]