Class: ActiveRecord::FutureResult::EventBuffer
- Inherits:
-
Object
- Object
- ActiveRecord::FutureResult::EventBuffer
- Defined in:
- lib/active_record/future_result.rb
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(future_result, instrumenter) ⇒ EventBuffer
constructor
A new instance of EventBuffer.
- #instrument(name, payload = {}, &block) ⇒ Object
Constructor Details
#initialize(future_result, instrumenter) ⇒ EventBuffer
Returns a new instance of EventBuffer.
6 7 8 9 10 |
# File 'lib/active_record/future_result.rb', line 6 def initialize(future_result, instrumenter) @future_result = future_result @instrumenter = instrumenter @events = [] end |
Instance Method Details
#flush ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/active_record/future_result.rb', line 18 def flush events, @events = @events, [] events.each do |event| event.payload[:lock_wait] = @future_result.lock_wait ActiveSupport::Notifications.publish_event(event) end end |
#instrument(name, payload = {}, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/active_record/future_result.rb', line 12 def instrument(name, payload = {}, &block) event = @instrumenter.new_event(name, payload) @events << event event.record(&block) end |