Class: Fidgit::Event::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/fidgit/event.rb

Overview

Created and returned by #subscribe and can be used to unsubscribe from the event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(publisher, event, handler) ⇒ Subscription

Returns a new instance of Subscription.

Raises:

  • (TypeError)

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

#eventObject (readonly)

Returns the value of attribute event


28
29
30
# File 'lib/fidgit/event.rb', line 28

def event
  @event
end

#handlerObject (readonly)

Returns the value of attribute handler


28
29
30
# File 'lib/fidgit/event.rb', line 28

def handler
  @handler
end

#publisherObject (readonly)

Returns the value of attribute publisher


28
29
30
# File 'lib/fidgit/event.rb', line 28

def publisher
  @publisher
end

Instance Method Details

#unsubscribeObject


38
39
40
# File 'lib/fidgit/event.rb', line 38

def unsubscribe
  @publisher.unsubscribe self
end