Class: Celluloid::Notifications::Subscriber
- Inherits:
-
Object
- Object
- Celluloid::Notifications::Subscriber
- Defined in:
- lib/celluloid/notifications.rb
Instance Attribute Summary collapse
-
#actor ⇒ Object
Returns the value of attribute actor.
-
#method ⇒ Object
Returns the value of attribute method.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(actor, pattern, method) ⇒ Subscriber
constructor
A new instance of Subscriber.
- #matches?(subscriber_or_pattern) ⇒ Boolean
- #publish(pattern, *args) ⇒ Object
- #subscribed_to?(pattern) ⇒ Boolean
Constructor Details
#initialize(actor, pattern, method) ⇒ Subscriber
Returns a new instance of Subscriber.
68 69 70 71 72 |
# File 'lib/celluloid/notifications.rb', line 68 def initialize(actor, pattern, method) @actor = actor @pattern = pattern @method = method end |
Instance Attribute Details
#actor ⇒ Object
Returns the value of attribute actor.
66 67 68 |
# File 'lib/celluloid/notifications.rb', line 66 def actor @actor end |
#method ⇒ Object
Returns the value of attribute method.
66 67 68 |
# File 'lib/celluloid/notifications.rb', line 66 def method @method end |
#pattern ⇒ Object
Returns the value of attribute pattern.
66 67 68 |
# File 'lib/celluloid/notifications.rb', line 66 def pattern @pattern end |
Instance Method Details
#matches?(subscriber_or_pattern) ⇒ Boolean
85 86 87 88 |
# File 'lib/celluloid/notifications.rb', line 85 def matches?(subscriber_or_pattern) self === subscriber_or_pattern || @pattern && @pattern === subscriber_or_pattern end |
#publish(pattern, *args) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/celluloid/notifications.rb', line 74 def publish(pattern, *args) actor.async method, pattern, *args rescue DeadActorError # TODO: needs a tests # Bad shutdown logic. Oh well.... end |
#subscribed_to?(pattern) ⇒ Boolean
81 82 83 |
# File 'lib/celluloid/notifications.rb', line 81 def subscribed_to?(pattern) !pattern || @pattern === pattern.to_s || @pattern === pattern end |