Class: AS::Notifications::Fanout::Subscribers::Evented

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

Overview

:nodoc:

Direct Known Subclasses

Timed

Instance Method Summary collapse

Constructor Details

#initialize(pattern, delegate) ⇒ Evented

Returns a new instance of Evented.



76
77
78
79
80
# File 'lib/as/notifications/fanout.rb', line 76

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

Instance Method Details

#finish(name, id, payload) ⇒ Object



92
93
94
# File 'lib/as/notifications/fanout.rb', line 92

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

#matches?(subscriber_or_name) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
103
# File 'lib/as/notifications/fanout.rb', line 100

def matches?(subscriber_or_name)
  self === subscriber_or_name ||
    @pattern && @pattern === subscriber_or_name
end

#publish(name, *args) ⇒ Object



82
83
84
85
86
# File 'lib/as/notifications/fanout.rb', line 82

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

#start(name, id, payload) ⇒ Object



88
89
90
# File 'lib/as/notifications/fanout.rb', line 88

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

#subscribed_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/as/notifications/fanout.rb', line 96

def subscribed_to?(name)
  @pattern === name.to_s
end