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.
27 28 29 30 31 |
# File 'lib/active_record/future_result.rb', line 27 def initialize(future_result, instrumenter) @future_result = future_result @instrumenter = instrumenter @events = [] end |
Instance Method Details
#flush ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/active_record/future_result.rb', line 39 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
33 34 35 36 37 |
# File 'lib/active_record/future_result.rb', line 33 def instrument(name, payload = {}, &block) event = @instrumenter.new_event(name, payload) @events << event event.record(&block) end |