123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::Testing::EventReporterAssertions::EventCollector

Do not use. This module is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Defined in: activesupport/lib/active_support/testing/event_reporter_assertions.rb

Class Method Summary

Class Method Details

.emit(event)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 46

def emit(event)
  event_recorders&.each do |events|
    events << Event.new(event)
  end
  true
end

.event_recorders (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 81

def event_recorders
  ActiveSupport::IsolatedExecutionState[:active_support_event_reporter_assertions] ||= []
end

.record

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 53

def record
  subscribe
  events = []
  event_recorders << events
  begin
    yield
    events
  ensure
    event_recorders.delete_if { |r| events.equal?(r) }
  end
end

.subscribe (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 66

def subscribe
  return if @subscribed

  @mutex.synchronize do
    unless @subscribed
      if ActiveSupport.event_reporter
        ActiveSupport.event_reporter.subscribe(self)
        @subscribed = true
      else
        raise Minitest::Assertion, "No event reporter is configured"
      end
    end
  end
end