Class: DynamicDelegator

Inherits:
BasicObject
Defined in:
lib/chain-boy/dynamic_delegator.rb

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ DynamicDelegator

Returns a new instance of DynamicDelegator.



2
3
4
# File 'lib/chain-boy/dynamic_delegator.rb', line 2

def initialize(target)
  @target = target
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



6
7
8
9
10
# File 'lib/chain-boy/dynamic_delegator.rb', line 6

def method_missing(*args, &block)
  result = @target.send(*args, &block)
  @target = result if result.kind_of? @target.class
  result
end