Class: ActiveSupport::Notifications::Fanout::Subscribers::Evented
  
  
  
  
  
    - Inherits:
 
    - 
      Object
      
        
          - Object
 
          
            - ActiveSupport::Notifications::Fanout::Subscribers::Evented
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/active_support/notifications/fanout.rb
 
  
  
 
Overview
  
  Instance Attribute Summary collapse
  
  
    
      Instance Method Summary
      collapse
    
    
  
  Constructor Details
  
    
  
  
    #initialize(pattern, delegate)  ⇒ Evented 
  
  
  
  
    
Returns a new instance of Evented.
   
 
  
  
    
      
185
186
187
188
189
190 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 185
def initialize(pattern, delegate)
  @pattern = Matcher.wrap(pattern)
  @delegate = delegate
  @can_publish = delegate.respond_to?(:publish)
  @can_publish_event = delegate.respond_to?(:publish_event)
end 
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    
Returns the value of attribute pattern.
   
 
  
  
    
      
183
184
185 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 183
def pattern
  @pattern
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #finish(name, id, payload)  ⇒ Object 
  
  
  
  
    
      
210
211
212 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 210
def finish(name, id, payload)
  @delegate.finish name, id, payload
end 
     | 
  
 
    
      
  
  
    #publish(name, *args)  ⇒ Object 
  
  
  
  
    
      
192
193
194
195
196 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 192
def publish(name, *args)
  if @can_publish
    @delegate.publish name, *args
  end
end
     | 
  
 
    
      
  
  
    #publish_event(event)  ⇒ Object 
  
  
  
  
    
      
198
199
200
201
202
203
204 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 198
def publish_event(event)
  if @can_publish_event
    @delegate.publish_event event
  else
    publish(event.name, event.time, event.end, event.transaction_id, event.payload)
  end
end
     | 
  
 
    
      
  
  
    #start(name, id, payload)  ⇒ Object 
  
  
  
  
    
      
206
207
208 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 206
def start(name, id, payload)
  @delegate.start name, id, payload
end 
     | 
  
 
    
      
  
  
    #subscribed_to?(name)  ⇒ Boolean 
  
  
  
  
    
      
214
215
216 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 214
def subscribed_to?(name)
  pattern === name
end 
     | 
  
 
    
      
  
  
    #unsubscribe!(name)  ⇒ Object 
  
  
  
  
    
      
218
219
220 
     | 
    
      # File 'lib/active_support/notifications/fanout.rb', line 218
def unsubscribe!(name)
  pattern.unsubscribe!(name)
end 
     |