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.


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

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


138
139
140
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 138

def pattern
  @pattern
end

Instance Method Details

#finish(name, id, payload) ⇒ Object


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

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

#matches?(name) ⇒ Boolean

Returns:

  • (Boolean)

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

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

#publish(name, *args) ⇒ Object


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

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

#start(name, id, payload) ⇒ Object


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

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

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)

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

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

#unsubscribe!(name) ⇒ Object


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

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