Module: AfterCommitAction::ActiveRecord
- Defined in:
- lib/after_commit_action.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
15 16 17 |
# File 'lib/after_commit_action.rb', line 15 def self.included(base) base.after_commit :_after_commit_hook end |
Instance Method Details
#_after_commit_hook ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/after_commit_action.rb', line 24 def _after_commit_hook begin until @_execute_after_commit.blank? @_execute_after_commit.shift.call end rescue => e if defined?(Exceptional) # Rails quietly swallows exceptions in after-commit actions; to avoid missing these # exceptions, we pass them to Exceptional explicitly Exceptional.context(:after_commit_entity => self.inspect) Exceptional.handle(e, "execute_after_commit") else Rails.logger.error "Error in execute_after_commit block: #{e.inspect}" end raise e end end |
#execute_after_commit(&block) ⇒ Object
19 20 21 22 |
# File 'lib/after_commit_action.rb', line 19 def execute_after_commit(&block) @_execute_after_commit ||= [] @_execute_after_commit<< block end |