Class: ActiveSupport::Testing::EventReporterAssertions::EventCollector::Event
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/testing/event_reporter_assertions.rb |
Class Method Summary
- .new(event_data) ⇒ Event constructor
Instance Attribute Summary
- #event_data readonly
Instance Method Summary
Constructor Details
.new(event_data) ⇒ Event
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 14
def initialize(event_data) @event_data = event_data end
Instance Attribute Details
#event_data (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 12
attr_reader :event_data
Instance Method Details
#inspect
[ GitHub ]# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 18
def inspect "#{event_data[:name]} (payload: #{event_data[:payload].inspect}, tags: #{event_data[: ].inspect})" end
#matches?(name, payload, tags) ⇒ Boolean
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 22
def matches?(name, payload, ) return false unless name.to_s == event_data[:name] if payload && payload.is_a?(Hash) return false unless matches_hash?(payload, :payload) end return false unless matches_hash?(, : ) true end
#matches_hash?(expected_hash, event_key) ⇒ Boolean
(private)
# File 'activesupport/lib/active_support/testing/event_reporter_assertions.rb', line 34
def matches_hash?(expected_hash, event_key) expected_hash.all? do |k, v| if v.is_a?(Regexp) event_data.dig(event_key, k).to_s.match?(v) else event_data.dig(event_key, k) == v end end end