Class: Smith::Events::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/smith/events/bus.rb

Instance Method Summary collapse

Constructor Details

#initializeScope

Returns a new instance of Scope.



6
7
8
# File 'lib/smith/events/bus.rb', line 6

def initialize
  @handles = []
end

Instance Method Details

#cancel_allObject



16
17
18
# File 'lib/smith/events/bus.rb', line 16

def cancel_all
  @handles.each(&:cancel)
end

#on(event_class) ⇒ Object



10
11
12
13
14
# File 'lib/smith/events/bus.rb', line 10

def on(event_class, **, &)
  handle = Events.on(event_class, **, &)
  @handles << handle
  handle
end