Module: ViewModel::AfterTransactionRunner
- Defined in:
- lib/view_model/after_transaction_runner.rb
Overview
Module implementing the behaviour of a AR post-transaction hook. After calling ‘add_to_transaction`, the abstract method `after_transaction` will be invoked by AR’s callbacks.
Instance Method Summary collapse
- #add_to_transaction ⇒ Object
- #after_commit ⇒ Object
- #after_rollback ⇒ Object
-
#before_commit ⇒ Object
Our simplified API.
- #before_committed! ⇒ Object
-
#committed! ⇒ Object
Rails’ internal API.
-
#connection ⇒ Object
Override to tie to a specific connection.
- #rolledback! ⇒ Object
- #trigger_transactional_callbacks? ⇒ Boolean
Instance Method Details
#add_to_transaction ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/view_model/after_transaction_runner.rb', line 32 def add_to_transaction if connection.transaction_open? connection.add_transaction_record(self) else before_commit after_commit end end |
#after_commit ⇒ Object
28 |
# File 'lib/view_model/after_transaction_runner.rb', line 28 def after_commit; end |
#after_rollback ⇒ Object
30 |
# File 'lib/view_model/after_transaction_runner.rb', line 30 def after_rollback; end |
#before_commit ⇒ Object
Our simplified API
26 |
# File 'lib/view_model/after_transaction_runner.rb', line 26 def before_commit; end |
#before_committed! ⇒ Object
12 13 14 |
# File 'lib/view_model/after_transaction_runner.rb', line 12 def before_committed! before_commit end |
#committed! ⇒ Object
Rails’ internal API
8 9 10 |
# File 'lib/view_model/after_transaction_runner.rb', line 8 def committed!(*) after_commit end |
#connection ⇒ Object
Override to tie to a specific connection.
42 43 44 |
# File 'lib/view_model/after_transaction_runner.rb', line 42 def connection ActiveRecord::Base.connection end |
#rolledback! ⇒ Object
16 17 18 |
# File 'lib/view_model/after_transaction_runner.rb', line 16 def rolledback!(*) after_rollback end |
#trigger_transactional_callbacks? ⇒ Boolean
20 21 22 |
# File 'lib/view_model/after_transaction_runner.rb', line 20 def trigger_transactional_callbacks? true end |