Class: DrunkMonkey::Controller
- Inherits:
-
Object
- Object
- DrunkMonkey::Controller
- Includes:
- Celluloid
- Defined in:
- lib/drunkmonkey.rb
Instance Method Summary collapse
- #fire(event, transport, message = nil) ⇒ Object
-
#initialize(name = :default_controller) ⇒ Controller
constructor
A new instance of Controller.
- #on(event, &block) ⇒ Object
Constructor Details
#initialize(name = :default_controller) ⇒ Controller
Returns a new instance of Controller.
12 13 14 15 |
# File 'lib/drunkmonkey.rb', line 12 def initialize name = :default_controller @handlers = Hash.new Actor[name] = Actor.current end |
Instance Method Details
#fire(event, transport, message = nil) ⇒ Object
23 24 25 26 |
# File 'lib/drunkmonkey.rb', line 23 def fire event, transport, = nil handler = @handlers[event] handler.call transport, if handler end |
#on(event, &block) ⇒ Object
17 18 19 |
# File 'lib/drunkmonkey.rb', line 17 def on event, &block @handlers[event] = block end |