Module SingleForwardable
In: lib/forwardable.rb

The SingleForwardable module provides delegation of specified methods to a designated object, using the methods def_delegator and def_delegators. This module is similar to Forwardable, but it works on objects themselves, instead of their defining classes.

Also see the example at forwardable.rb.

Methods

Public Instance methods

def_delegator(accessor, method, ali = method)
def_delegators(accessor, *methods)

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.

Shortcut for defining multiple delegator methods, but with no provision for using a different name. The following two code samples have the same effect:

  single_forwardable.def_delegators :@records, :size, :<<, :map

  single_forwardable.def_delegator :@records, :size
  single_forwardable.def_delegator :@records, :<<
  single_forwardable.def_delegator :@records, :map

See the example at forwardable.rb.

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Rising Tide Software, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.