Module: ViewModel::AfterTransactionRunner
- Extended by:
- ActiveSupport::Concern
- 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
49 50 51 52 53 54 55 56 |
# File 'lib/view_model/after_transaction_runner.rb', line 49 def add_to_transaction if connection.transaction_open? connection.add_transaction_record(self) else before_commit after_commit end end |
#after_commit ⇒ Object
45 |
# File 'lib/view_model/after_transaction_runner.rb', line 45 def after_commit; end |
#after_rollback ⇒ Object
47 |
# File 'lib/view_model/after_transaction_runner.rb', line 47 def after_rollback; end |
#before_commit ⇒ Object
Our simplified API
43 |
# File 'lib/view_model/after_transaction_runner.rb', line 43 def before_commit; end |
#before_committed! ⇒ Object
29 30 31 |
# File 'lib/view_model/after_transaction_runner.rb', line 29 def before_committed! before_commit end |
#committed! ⇒ Object
Rails’ internal API
25 26 27 |
# File 'lib/view_model/after_transaction_runner.rb', line 25 def committed!(*) after_commit end |
#connection ⇒ Object
Override to tie to a specific connection.
59 60 61 |
# File 'lib/view_model/after_transaction_runner.rb', line 59 def connection ActiveRecord::Base.connection end |
#rolledback! ⇒ Object
33 34 35 |
# File 'lib/view_model/after_transaction_runner.rb', line 33 def rolledback!(*) after_rollback end |
#trigger_transactional_callbacks? ⇒ Boolean
37 38 39 |
# File 'lib/view_model/after_transaction_runner.rb', line 37 def trigger_transactional_callbacks? true end |