Module: CamperVan::CommandDefinition::InstanceMethods
- Defined in:
- lib/camper_van/command_definition.rb
Instance Method Summary collapse
-
#handle(command) ⇒ Object
Public: handles the given command using the handler method defined by the class-level handler metaprogramming, if it exists.
Instance Method Details
#handle(command) ⇒ Object
Public: handles the given command using the handler method defined by the class-level handler metaprogramming, if it exists.
command - the Hash command as provided by the irc command parser
Example:
handle :nick => ["joe"]
Raises CamperVan::HandlerMissing if there is no handler method
defined for the given command.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/camper_van/command_definition.rb', line 53 def handle(command) name, args = command.to_a.first method_name = "handle_#{name}".to_sym if self.respond_to? method_name m = method(method_name) if m.arity > 0 send method_name, args else send method_name end else raise CamperVan::HandlerMissing, command end end |