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

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

Overview

:nodoc:

Direct Known Subclasses

EventObject, Timed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, delegate) ⇒ Evented

Returns a new instance of Evented.



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

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.



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

def pattern
  @pattern
end

Instance Method Details

#finish(name, id, payload) ⇒ Object



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

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

#matches?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#publish(name, *args) ⇒ Object



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

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

#start(name, id, payload) ⇒ Object



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

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

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#unsubscribe!(name) ⇒ Object



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

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