Module: Onfire::Event::ProcessingMethods

Included in:
Onfire::Event
Defined in:
lib/onfire/event.rb

Instance Method Summary collapse

Instance Method Details

#bubble!Object



25
26
27
28
29
# File 'lib/onfire/event.rb', line 25

def bubble!
  node = source
  # in a real visitor pattern, the visited would call #process_node.
  begin process_node(node) end while node = node.parent
end

#call_handler(proc, node) ⇒ Object



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

def call_handler(proc, node)
  proc.call(self)
end

#process_node(node) ⇒ Object



31
32
33
34
35
36
# File 'lib/onfire/event.rb', line 31

def process_node(node)
  node.handlers_for_event(self).each do |proc|
    return if stopped?
    call_handler(proc, node)
  end
end