Module: Artoo::Delegator
- Defined in:
- lib/artoo/delegator.rb
Overview
Artoo delegation mixin that acts like Sinatra. Mixing this module into an object causes all methods to be delegated to the Artoo::MainRobot class. Used primarily at the top-level.
Class Attribute Summary collapse
-
.target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
-
.delegate(*methods) ⇒ Object
:nodoc:.
Class Attribute Details
.target ⇒ Object
Returns the value of attribute target.
36 37 38 |
# File 'lib/artoo/delegator.rb', line 36 def target @target end |
Class Method Details
.delegate(*methods) ⇒ Object
:nodoc:
23 24 25 26 27 28 29 30 31 |
# File 'lib/artoo/delegator.rb', line 23 def self.delegate(*methods) methods.each do |method_name| define_method(method_name) do |*args, &block| return super(*args, &block) if respond_to? method_name Delegator.target.send(method_name, *args, &block) end private method_name end end |