Skip to content

Commit 5e91bc4

Browse files
authored
Merge pull request rails#44456 from jhawthorn/fanout_inspect
Implement inspect for Notifications::Fanout
2 parents 0dbe699 + e1a4061 commit 5e91bc4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

activesupport/lib/active_support/notifications/fanout.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ def unsubscribe(subscriber_or_name)
6868
end
6969
end
7070

71+
def inspect # :nodoc:
72+
total_patterns = @string_subscribers.size + @other_subscribers.size
73+
"#<#{self.class} (#{total_patterns} patterns)>"
74+
end
75+
7176
def start(name, id, payload)
7277
iterate_guarding_exceptions(listeners_for(name)) { |s| s.start(name, id, payload) }
7378
end

activesupport/test/notifications_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ def test_monotonic_timed_subscribed
231231
end
232232
end
233233

234+
class InspectTest < TestCase
235+
def test_inspect_output_is_small
236+
expected = "#<ActiveSupport::Notifications::Fanout (2 patterns)>"
237+
assert_equal expected, @notifier.inspect
238+
end
239+
end
240+
234241
class UnsubscribeTest < TestCase
235242
def test_unsubscribing_removes_a_subscription
236243
@notifier.publish :foo

0 commit comments

Comments
 (0)