Class: Onfire::Event

Inherits:
Object
  • Object
show all
Includes:
ProcessingMethods
Defined in:
lib/onfire/event.rb,
lib/onfire/debugging.rb

Overview

An event carries a type, source, and optional payload. Calling #bubble! it starts at its source and traverses up the hierarchy using #parent. On every node it calls #handlers_for_event on the node while calling returned procs.

Defined Under Namespace

Modules: Debugging, ProcessingMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ProcessingMethods

#bubble!, #call_handler, #process_node

Constructor Details

#initialize(type, source, data = nil) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
# File 'lib/onfire/event.rb', line 9

def initialize(type, source, data=nil)
  @type       = type
  @source     = source
  @data       = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/onfire/event.rb', line 7

def data
  @data
end

#sourceObject

Returns the value of attribute source.



7
8
9
# File 'lib/onfire/event.rb', line 7

def source
  @source
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/onfire/event.rb', line 7

def type
  @type
end

Instance Method Details

#stop!Object

Stop event bubbling.



20
21
22
# File 'lib/onfire/event.rb', line 20

def stop!
  @stopped = true
end

#stopped?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/onfire/event.rb', line 15

def stopped?
  @stopped ||= false
end