Class: ActiveSupport::Notifications::Fanout::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/notifications/fanout.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(pattern, delegate) ⇒ Subscriber

Returns a new instance of Subscriber.



41
42
43
44
# File 'lib/active_support/notifications/fanout.rb', line 41

def initialize(pattern, delegate)
  @pattern = pattern
  @delegate = delegate
end

Instance Method Details

#matches?(subscriber_or_name) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/active_support/notifications/fanout.rb', line 54

def matches?(subscriber_or_name)
  self === subscriber_or_name ||
    @pattern && @pattern === subscriber_or_name
end

#publish(message, *args) ⇒ Object



46
47
48
# File 'lib/active_support/notifications/fanout.rb', line 46

def publish(message, *args)
  @delegate.call(message, *args)
end

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/active_support/notifications/fanout.rb', line 50

def subscribed_to?(name)
  !@pattern || @pattern === name.to_s
end