Multiplexing Delegator plugin

Plugin details

MultiplexingDelegator is used to define a delegator method that multiplexes calls from one method across many methods for an instance of an object. The class method is usable for any type of Object, but was intended for use within an ActiveRecord object.

Websitehttp://glomp.rubyforge.org/multiplexing_delegator/ Repositoryhttp://glomp.rubyforge.org/svn/plugins/multiplexing_delegator/ Tags ActiveRecord LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://glomp.rubyforge.org/svn/plugins/multiplexing_delegator/

The delegator works by calling the same method across multiple methods or accessors for a given object instance and aggregating the results.

Example

 class Foo
   attr_accessor :baz, :bum
   multiplex :bar, :on => [:baz, :bum]
 end

 foo = Foo.new
 foo.baz = 1
 foo.bum = ['boo']
 foo.bar.map => [1, 'boo']



You can also proxy method calls to each of the delegated items and results will be aggregated.

Example

 class Goo
   attr_accessor :car
   def initialize(car) @car = car; end
 end

 foo = Foo.new
 foo.baz = Goo.new('hello')
 foo.bum = Goo.new('world')
 foo.bar.car => ['hello, 'world']

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, 10 months ago