Method: AutomateIt::Plugin::Manager#dispatch

Defined in:
lib/automateit/plugin/manager.rb

#dispatch(*args, &block) ⇒ Object

Dispatch a method by guessing its name. This is the recommended way to write wrappers for a Manager methods.

Example:

class MyManager < Plugin::Manager
  # Your RDoc here
  def my_method(*args)
    # Will guess that you want to +dispatch_to+ the +my_method+ by
    # introspecting the name of the wrapper method.
    dispatch(*args)
  end
  ...
end


123
124
125
126
127
# File 'lib/automateit/plugin/manager.rb', line 123

def dispatch(*args, &block)
  # Extract caller's method as symbol to save user from having to specify it
  method = caller[0].match(/:in `(.+?)'/)[1].to_sym
  dispatch_to(method, *args, &block)
end