Class: ActiveSupport::Notifications::Fanout::Subscribers::Evented

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

Overview

:nodoc:

Direct Known Subclasses

Timed

Instance Method Summary collapse

Constructor Details

#initialize(pattern, delegate) ⇒ Evented

Returns a new instance of Evented.



79
80
81
82
83
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 79

def initialize(pattern, delegate)
  @pattern = pattern
  @delegate = delegate
  @can_publish = delegate.respond_to?(:publish)
end

Instance Method Details

#finish(name, id, payload) ⇒ Object



95
96
97
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 95

def finish(name, id, payload)
  @delegate.finish name, id, payload
end

#matches?(subscriber_or_name) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
106
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 103

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

#publish(name, *args) ⇒ Object



85
86
87
88
89
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 85

def publish(name, *args)
  if @can_publish
    @delegate.publish name, *args
  end
end

#start(name, id, payload) ⇒ Object



91
92
93
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 91

def start(name, id, payload)
  @delegate.start name, id, payload
end

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 99

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