Module: Jabbot::Handlers
- Included in:
- Bot
- Defined in:
- lib/jabbot/handlers.rb
Instance Method Summary collapse
-
#add_handler(type, handler) ⇒ Object
Public: Add a handler for a given type.
-
#dispatch(type, message) ⇒ Object
Public: Dispatch a message based on is type.
-
#handlers ⇒ Object
Internal: Setup Arrays of all handler types.
-
#handlers=(hash) ⇒ Object
Deprecated: Set the handler types and Arrays.
Instance Method Details
#add_handler(type, handler) ⇒ Object
Public: Add a handler for a given type.
type - The Symbol representation of the type to be handled. handler - The Jabbot::Handler instance to handle a message.
Returns the handler.
9 10 11 12 |
# File 'lib/jabbot/handlers.rb', line 9 def add_handler(type, handler) handlers[type] << handler handler end |
#dispatch(type, message) ⇒ Object
Public: Dispatch a message based on is type.
type - The Symbol representation of the type to be dispatched. message - The String message to be handled.
Returns nothing.
20 21 22 |
# File 'lib/jabbot/handlers.rb', line 20 def dispatch(type, ) handlers[type].each {|handler| handler.dispatch() } end |
#handlers ⇒ Object
Internal: Setup Arrays of all handler types.
Returns a Hash containing the possible handler types and
its associated Arrays of handlers.
28 29 30 31 32 33 34 35 36 |
# File 'lib/jabbot/handlers.rb', line 28 def handlers @handlers ||= { :message => [], :private => [], :join => [], :subject => [], :leave => [] } end |
#handlers=(hash) ⇒ Object
Deprecated: Set the handler types and Arrays
hash - A hash containing the handler types and associated Arrays
(see `handlers`).
Returns nothing.
44 45 46 |
# File 'lib/jabbot/handlers.rb', line 44 def handlers=(hash) @handlers = hash end |