Class: Yeller::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/yeller/subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subscriber_class, method, key) ⇒ Subscriber

Returns a new instance of Subscriber.



5
6
7
8
9
# File 'lib/yeller/subscriber.rb', line 5

def initialize( subscriber_class, method, key )
  @subscriber_class = subscriber_class
  @method           = method
  @key              = key
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/yeller/subscriber.rb', line 3

def key
  @key
end

#methodObject

Returns the value of attribute method.



3
4
5
# File 'lib/yeller/subscriber.rb', line 3

def method
  @method
end

#subscriber_classObject

Returns the value of attribute subscriber_class.



3
4
5
# File 'lib/yeller/subscriber.rb', line 3

def subscriber_class
  @subscriber_class
end

Instance Method Details

#==(comparison_object) ⇒ Object



11
12
13
14
15
16
# File 'lib/yeller/subscriber.rb', line 11

def ==( comparison_object )
  comparison_object.equal?(self) ||
  ( comparison_object.instance_of?(self.class) &&
    comparison_object.method == method &&
    comparison_object.key == key )
end

#notify(message) ⇒ Object



18
19
20
21
22
# File 'lib/yeller/subscriber.rb', line 18

def notify( message )
  Thread.new do
    subscriber_class.send( method, message )
  end
end