Module: Isolator::Callbacks
- Included in:
- Isolator
- Defined in:
- lib/isolator/callbacks.rb
Overview
Add before_isolate and after_isolate callbacks
Instance Method Summary collapse
- #after_isolate(&block) ⇒ Object
- #after_isolate_callbacks ⇒ Object
- #before_isolate(&block) ⇒ Object
- #before_isolate_callbacks ⇒ Object
- #finish! ⇒ Object
- #notify!(event, payload) ⇒ Object
- #on_transaction_begin(&block) ⇒ Object
- #on_transaction_end(&block) ⇒ Object
- #start! ⇒ Object
- #transaction_begin_callbacks ⇒ Object
- #transaction_end_callbacks ⇒ Object
Instance Method Details
#after_isolate(&block) ⇒ Object
10 11 12 |
# File 'lib/isolator/callbacks.rb', line 10 def after_isolate(&block) after_isolate_callbacks << block end |
#after_isolate_callbacks ⇒ Object
44 45 46 |
# File 'lib/isolator/callbacks.rb', line 44 def after_isolate_callbacks @after_isolate_callbacks ||= [] end |
#before_isolate(&block) ⇒ Object
6 7 8 |
# File 'lib/isolator/callbacks.rb', line 6 def before_isolate(&block) before_isolate_callbacks << block end |
#before_isolate_callbacks ⇒ Object
40 41 42 |
# File 'lib/isolator/callbacks.rb', line 40 def before_isolate_callbacks @before_isolate_callbacks ||= [] end |
#finish! ⇒ Object
27 28 29 30 |
# File 'lib/isolator/callbacks.rb', line 27 def finish! return if Isolator.disabled? after_isolate_callbacks.each(&:call) end |
#notify!(event, payload) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/isolator/callbacks.rb', line 32 def notify!(event, payload) if event == :begin transaction_begin_callbacks.each { |cb| cb.call(payload) } elsif event == :end transaction_end_callbacks.each { |cb| cb.call(payload) } end end |
#on_transaction_begin(&block) ⇒ Object
14 15 16 |
# File 'lib/isolator/callbacks.rb', line 14 def on_transaction_begin(&block) transaction_begin_callbacks << block end |
#on_transaction_end(&block) ⇒ Object
18 19 20 |
# File 'lib/isolator/callbacks.rb', line 18 def on_transaction_end(&block) transaction_end_callbacks << block end |
#start! ⇒ Object
22 23 24 25 |
# File 'lib/isolator/callbacks.rb', line 22 def start! return if Isolator.disabled? before_isolate_callbacks.each(&:call) end |
#transaction_begin_callbacks ⇒ Object
48 49 50 |
# File 'lib/isolator/callbacks.rb', line 48 def transaction_begin_callbacks @transaction_begin_callbacks ||= [] end |
#transaction_end_callbacks ⇒ Object
52 53 54 |
# File 'lib/isolator/callbacks.rb', line 52 def transaction_end_callbacks @transaction_end_callbacks ||= [] end |