Class: Delegator

Inherits:
BasicObject
Defined in:
opal/stdlib/delegate.rb

Direct Known Subclasses

SimpleDelegator

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Delegator

Returns a new instance of Delegator.



2
3
4
# File 'opal/stdlib/delegate.rb', line 2

def initialize(obj)
  __setobj__(obj)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'opal/stdlib/delegate.rb', line 6

def method_missing(m, *args, &block)
  target = __getobj__

  if target.respond_to?(m)
    target.__send__(m, *args, &block)
  else
    super(m, *args, &block)
  end
end