Module: ArTransactionChanges

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

Constant Summary collapse

VERSION =
"1.1.0"

Instance Method Summary collapse

Instance Method Details

#_run_commit_callbacksObject



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

def _run_commit_callbacks
  super
ensure
  @transaction_changed_attributes = nil
end

#_run_create_callbacksObject



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

def _run_create_callbacks
  ret = super
  store_transaction_changed_attributes if ret != false
  ret
end

#_run_rollback_callbacksObject



23
24
25
26
27
# File 'lib/ar_transaction_changes.rb', line 23

def _run_rollback_callbacks
  super
ensure
  @transaction_changed_attributes = nil
end

#_run_update_callbacksObject



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

def _run_update_callbacks
  ret = super
  store_transaction_changed_attributes if ret != false
  ret
end

#run_callbacks(kind, *args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ar_transaction_changes.rb', line 29

def run_callbacks(kind, *args)
  ret = super
  case kind.to_sym
  when :create, :update
    store_transaction_changed_attributes if ret != false
  when :commit, :rollback
    @transaction_changed_attributes = nil
  end

  ret
end

#transaction_changed_attributesObject



42
43
44
# File 'lib/ar_transaction_changes.rb', line 42

def transaction_changed_attributes
  changed_attributes.merge(@transaction_changed_attributes ||= {})
end