Module: ArTransactionChanges

Defined in:
lib/ar_transaction_changes.rb,
lib/ar_transaction_changes/version.rb

Constant Summary collapse

VERSION =
"1.1.5"

Instance Method Summary collapse

Instance Method Details

#_run_commit_callbacksObject



5
6
7
8
9
# File 'lib/ar_transaction_changes.rb', line 5

def _run_commit_callbacks
  super
ensure
  @transaction_changed_attributes = nil
end

#_run_rollback_callbacksObject



11
12
13
14
15
# File 'lib/ar_transaction_changes.rb', line 11

def _run_rollback_callbacks
  super
ensure
  @transaction_changed_attributes = nil
end

#_write_attribute(attr_name, value) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/ar_transaction_changes.rb', line 21

def _write_attribute(attr_name, value)
  attr_name = attr_name.to_s
  old_value = read_attribute(attr_name)
  ret = super(attr_name, value)
  new_value = read_attribute(attr_name)
  unless transaction_changed_attributes.key?(attr_name) || new_value == old_value
    transaction_changed_attributes[attr_name] = old_value
  end
  ret
end

#transaction_changed_attributesObject



17
18
19
# File 'lib/ar_transaction_changes.rb', line 17

def transaction_changed_attributes
  @transaction_changed_attributes ||= HashWithIndifferentAccess.new
end