Module: Chatroid::Callback
- Included in:
- Chatroid
- Defined in:
- lib/chatroid/callback.rb
Instance Method Summary collapse
-
#method_missing(method_name, *args, &block) ⇒ Object
You can call methods like this: * list_message : return Array of callbacks for “message” * on_message : store a given block as callback for “message” * trigger_message : trigger callbacks for “message” with given args.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
You can call methods like this:
-
list_message : return Array of callbacks for “message”
-
on_message : store a given block as callback for “message”
-
trigger_message : trigger callbacks for “message” with given args
7 8 9 10 11 12 13 |
# File 'lib/chatroid/callback.rb', line 7 def method_missing(method_name, *args, &block) if method_name =~ /(list|on|trigger)_([a-z0-9]+)/ send($1, $2, *args, &block) else super end end |