# Forwardable (Module)

In: | forwardable.rb

      forwardable.rb -
          $Release Version: 1.1$
          $Revision: 1.2 $
          $Date: 2001/11/03 13:41:57 $
          by Keiju ISHITSUKA(keiju@ishitsuka.com)
          original definition by delegator.rb

— Usage:

      class Foo
        extend Forwardable

        def_delegators("@out", "printf", "print")
        def_delegators(:@in, :gets)
        def_delegator(:@contents, :[], "content_at")
      end
      f = Foo.new
      f.printf ...
      f.gets
      f.content_at(1)

      g = Goo.new
      g.extend SingleForwardable
      g.def_delegator("@out", :puts)
      g.puts ...

## Methods

def_delegator def_delegators def_instance_delegator def_instance_delegators

## Attributes

debug | [RW] |

## Public Instance methods

def_instance_delegators(accessor, *methods)

[Source]

    # File forwardable.rb, line 37
      def def_instance_delegators(accessor, *methods)
        for method in methods
          def_instance_delegator(accessor, method)
        end
      end

def_instance_delegator(accessor, method, ali = method)

[Source]

    # File forwardable.rb, line 43
      def def_instance_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)

        module_eval("def \#{ali}(*args, &block)\nbegin\n\#{accessor}.__send__(:\#{method}, *args, &block)\nrescue Exception\n$@.delete_if{|s| /^\\\\(__FORWARDABLE__\\\\):/ =~ s} unless Forwardable::debug\nKernel::raise\nend\nend\n", "(__FORWARDABLE__)", 1)
      end

def_delegators(accessor, *methods)

Alias for def_instance_delegators

def_delegator(accessor, method, ali = method)

Alias for def_instance_delegator

[Validate]