Module: Twibot::Handlers
- Included in:
- Bot
- Defined in:
- lib/twibot/handlers.rb
Instance Method Summary collapse
-
#add_handler(type, handler) ⇒ Object
Add a handler for this bot.
- #dispatch(type, message) ⇒ Object
- #handlers ⇒ Object
- #handlers=(hash) ⇒ Object
Instance Method Details
#add_handler(type, handler) ⇒ Object
Add a handler for this bot
6 7 8 9 |
# File 'lib/twibot/handlers.rb', line 6 def add_handler(type, handler) handlers[type] << handler handler end |
#dispatch(type, message) ⇒ Object
11 12 13 |
# File 'lib/twibot/handlers.rb', line 11 def dispatch(type, ) handlers[type].each { |handler| handler.dispatch() } end |
#handlers ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/twibot/handlers.rb', line 15 def handlers @handlers ||= { :message => [], :reply => [], :tweet => [] } end |
#handlers=(hash) ⇒ Object
23 24 25 |
# File 'lib/twibot/handlers.rb', line 23 def handlers=(hash) @handlers = hash end |