lib/kasket/write_mixin.rb in kasket-4.10.2.1 vs lib/kasket/write_mixin.rb in kasket-4.10.4
- old
+ new
@@ -38,10 +38,15 @@
end
def kasket_keys(options = {})
attribute_sets = [attributes]
- previous_changes = options[:previous_changes] || previous_changes()
+ previous_changes = options[:previous_changes]
+ previous_changes ||= if respond_to?(:saved_changes)
+ saved_changes.transform_values(&:first)
+ else
+ previous_changes() # keep parens or rename the local var
+ end
if previous_changes.present?
old_attributes = previous_changes.each_with_object({}) do |(attribute, (old, _)), all|
all[attribute.to_s] = old
end
attribute_sets << old_attributes.reverse_merge(attribute_sets[0])