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, Timed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, delegate) ⇒ Evented

Returns a new instance of Evented.



376
377
378
379
380
381
382
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 376

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

Instance Attribute Details

#delegateObject (readonly)

Returns the value of attribute delegate



374
375
376
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 374

def delegate
  @delegate
end

#patternObject (readonly)

Returns the value of attribute pattern



374
375
376
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 374

def pattern
  @pattern
end

#silenceableObject (readonly)

Returns the value of attribute silenceable



374
375
376
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 374

def silenceable
  @silenceable
end

Instance Method Details

#group_classObject



384
385
386
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 384

def group_class
  EventedGroup
end

#publish(name, *args) ⇒ Object



388
389
390
391
392
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 388

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

#publish_event(event) ⇒ Object



394
395
396
397
398
399
400
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 394

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

#silenced?(name) ⇒ Boolean

Returns:

  • (Boolean)


402
403
404
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 402

def silenced?(name)
  @silenceable && @delegate.silenced?(name)
end

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


406
407
408
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 406

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

#unsubscribe!(name) ⇒ Object



410
411
412
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 410

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