Class: ActiveSupport::Notifications::Fanout::Subscriber
- Defined in:
- lib/active_support/notifications/fanout.rb
Overview
:nodoc:
Instance Method Summary collapse
- #drained? ⇒ Boolean
-
#initialize(pattern, &block) ⇒ Subscriber
constructor
A new instance of Subscriber.
- #matches?(subscriber_or_name) ⇒ Boolean
- #publish(*args) ⇒ Object
- #subscribed_to?(name) ⇒ Boolean
Constructor Details
#initialize(pattern, &block) ⇒ Subscriber
Returns a new instance of Subscriber.
57 58 59 60 |
# File 'lib/active_support/notifications/fanout.rb', line 57 def initialize(pattern, &block) @pattern = pattern @block = block end |
Instance Method Details
#drained? ⇒ Boolean
68 69 70 |
# File 'lib/active_support/notifications/fanout.rb', line 68 def drained? true end |
#matches?(subscriber_or_name) ⇒ Boolean
76 77 78 79 80 81 82 83 |
# File 'lib/active_support/notifications/fanout.rb', line 76 def matches?(subscriber_or_name) case subscriber_or_name when String @pattern && @pattern =~ subscriber_or_name when self true end end |
#publish(*args) ⇒ Object
62 63 64 65 66 |
# File 'lib/active_support/notifications/fanout.rb', line 62 def publish(*args) return unless subscribed_to?(args.first) push(*args) true end |
#subscribed_to?(name) ⇒ Boolean
72 73 74 |
# File 'lib/active_support/notifications/fanout.rb', line 72 def subscribed_to?(name) !@pattern || @pattern =~ name.to_s end |