Class: Fidgit::Event::Subscription
Overview
Created and returned by #subscribe and can be used to unsubscribe from the event.
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
Instance Method Summary collapse
-
#initialize(publisher, event, handler) ⇒ Subscription
constructor
A new instance of Subscription.
- #unsubscribe ⇒ Object
Constructor Details
#initialize(publisher, event, handler) ⇒ Subscription
Returns a new instance of Subscription.
30 31 32 33 34 35 36 |
# File 'lib/fidgit/event.rb', line 30 def initialize(publisher, event, handler) raise TypeError unless publisher.is_a? Event raise TypeError unless event.is_a? Symbol raise TypeError unless handler.is_a? Proc or handler.is_a? Method @publisher, @event, @handler = publisher, event, handler end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
28 29 30 |
# File 'lib/fidgit/event.rb', line 28 def event @event end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
28 29 30 |
# File 'lib/fidgit/event.rb', line 28 def handler @handler end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
28 29 30 |
# File 'lib/fidgit/event.rb', line 28 def publisher @publisher end |
Instance Method Details
#unsubscribe ⇒ Object
38 39 40 |
# File 'lib/fidgit/event.rb', line 38 def unsubscribe @publisher.unsubscribe self end |