Class: ActiveRecord::FutureResult::EventBuffer
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/future_result.rb |
Class Method Summary
- .new(future_result, instrumenter) ⇒ EventBuffer constructor
Instance Method Summary
Constructor Details
.new(future_result, instrumenter) ⇒ EventBuffer
# File 'activerecord/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
[ GitHub ]# File 'activerecord/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)
[ GitHub ]# File 'activerecord/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