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

EventObject, MonotonicTimed, Timed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, delegate) ⇒ Evented

Returns a new instance of Evented.



144
145
146
147
148
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 144

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

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern



142
143
144
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 142

def pattern
  @pattern
end

Instance Method Details

#finish(name, id, payload) ⇒ Object



160
161
162
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 160

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

#matches?(name) ⇒ Boolean

Returns:

  • (Boolean)


168
169
170
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 168

def matches?(name)
  pattern && pattern === name
end

#publish(name, *args) ⇒ Object



150
151
152
153
154
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 150

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

#start(name, id, payload) ⇒ Object



156
157
158
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 156

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

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 164

def subscribed_to?(name)
  pattern === name
end

#unsubscribe!(name) ⇒ Object



172
173
174
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 172

def unsubscribe!(name)
  pattern.unsubscribe!(name)
end