Class: Celluloid::Notifications::Subscriber

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor, pattern, method) ⇒ Subscriber

Returns a new instance of Subscriber.


63
64
65
66
67
# File 'lib/celluloid/notifications.rb', line 63

def initialize(actor, pattern, method)
  @actor = actor
  @pattern = pattern
  @method = method
end

Instance Attribute Details

#actorObject

Returns the value of attribute actor


61
62
63
# File 'lib/celluloid/notifications.rb', line 61

def actor
  @actor
end

#methodObject

Returns the value of attribute method


61
62
63
# File 'lib/celluloid/notifications.rb', line 61

def method
  @method
end

#patternObject

Returns the value of attribute pattern


61
62
63
# File 'lib/celluloid/notifications.rb', line 61

def pattern
  @pattern
end

Instance Method Details

#matches?(subscriber_or_pattern) ⇒ Boolean

Returns:

  • (Boolean)

77
78
79
80
# File 'lib/celluloid/notifications.rb', line 77

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

#publish(pattern, *args) ⇒ Object


69
70
71
# File 'lib/celluloid/notifications.rb', line 69

def publish(pattern, *args)
  actor.async method, pattern, *args
end

#subscribed_to?(pattern) ⇒ Boolean

Returns:

  • (Boolean)

73
74
75
# File 'lib/celluloid/notifications.rb', line 73

def subscribed_to?(pattern)
  !pattern || @pattern === pattern.to_s || @pattern === pattern
end