Module Onfire
In: lib/onfire/debugging.rb
lib/onfire/version.rb
lib/onfire/event.rb
lib/onfire/event_table.rb
lib/onfire.rb

Methods

Classes and Modules

Class Onfire::Event
Class Onfire::EventTable

Constants

VERSION = '0.2.0'

Public Instance methods

Fires an event which will bubble up starting from the receiver. While bubbling, the events checks the traversed object for matching observers and calls the handlers in the order they were attached.

Notice that you can append payload data to the event object.

  fire :click, :time => Time.now

The payload is accessable in the data attribute.

  evt.data[:time] # => 2011-03-12 11:25:57 +0100

Get all handlers from self for the passed event (interface for Event).

Attachs an event observer to the receiver which is called by a matching event.

The handler might be a block receiving the triggering event.

  matz.on :applaus do |evt|
    puts "grin"
  end

You can also pass a callable object as handler.

  class GrinHandler
    def call(evt)
      puts "grin"
    end
  end

  matz.on :applaus, :do => GrinHandler.new

The +:from+ option allows conditional filtering.

  matz.on :applaus, :from => audience do |evt|

This handler is called only if audience trigger the +:applaus+ event.

Protected Instance methods

Factory method for creating the event. Override if you want your own event.

[Validate]