def_singleton_delegator(accessor, method, ali = method)
public
Defines a method method which delegates to obj (i.e. it
calls the method of the same name in obj). If new_name is
provided, it is used as the name for the delegate method.
See the example at forwardable.rb.
# File lib/forwardable.rb, line 200
def def_singleton_delegator(accessor, method, ali = method)
accessor = accessor.id2name if accessor.kind_of?(Integer)
method = method.id2name if method.kind_of?(Integer)
ali = ali.id2name if ali.kind_of?(Integer)
instance_eval("def \#{ali}(*args, &block)\nbegin\n\#{accessor}.__send__(:\#{method}, *args,&block)\nrescue Exception\[email protected]_if{|s| /^\\\\(__FORWARDABLE__\\\\):/ =~ s} unless Forwardable::debug\nKernel::raise\nend\nend\n", "(__FORWARDABLE__)", 1)
end