Module: ActiveRecord::AfterTransaction::Methods
- Defined in:
- lib/activerecord-after-transaction/methods.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/activerecord-after-transaction/methods.rb', line 5 def self.included(klass) klass.class_eval do after_commit :execute_after_transaction after_rollback :clear_after_transaction end end |
Instance Method Details
#after_transaction(&block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/activerecord-after-transaction/methods.rb', line 12 def after_transaction(&block) return block.call if self.class.connection.open_transactions == 0 self.class.connection.add_transaction_record self @after_transaction_queue ||= [] @after_transaction_queue.push block logger && logger.debug("Push #{block}") end |