Class: Plutonium::Lib::AfterCommit
- Inherits:
-
Object
- Object
- Plutonium::Lib::AfterCommit
- Defined in:
- lib/plutonium/lib/after_commit.rb
Class Method Summary collapse
Instance Method Summary collapse
- #before_committed! ⇒ Object
- #committed! ⇒ Object
-
#initialize(rolled_back: false, &block) ⇒ AfterCommit
constructor
A new instance of AfterCommit.
- #rolledback! ⇒ Object
- #trigger_transactional_callbacks? ⇒ Boolean
Constructor Details
#initialize(rolled_back: false, &block) ⇒ AfterCommit
Returns a new instance of AfterCommit.
6 7 8 9 |
# File 'lib/plutonium/lib/after_commit.rb', line 6 def initialize(rolled_back: false, &block) @rolled_back = rolled_back @callback = block end |
Class Method Details
.execute(rolled_back: false, connection: ActiveRecord::Base.connection) ⇒ Object
27 28 29 30 |
# File 'lib/plutonium/lib/after_commit.rb', line 27 def execute(rolled_back: false, connection: ActiveRecord::Base.connection, &) connection.transaction_open? ? connection.add_transaction_record(AfterCommit.new(rolled_back: rolled_back, &)) : yield nil end |
Instance Method Details
#before_committed! ⇒ Object
15 16 |
# File 'lib/plutonium/lib/after_commit.rb', line 15 def before_committed!(*) end |
#committed! ⇒ Object
11 12 13 |
# File 'lib/plutonium/lib/after_commit.rb', line 11 def committed!(*) @callback.call end |
#rolledback! ⇒ Object
18 19 20 |
# File 'lib/plutonium/lib/after_commit.rb', line 18 def rolledback!(*) @callback.call if @rolled_back end |
#trigger_transactional_callbacks? ⇒ Boolean
22 23 24 |
# File 'lib/plutonium/lib/after_commit.rb', line 22 def trigger_transactional_callbacks? true end |