fast_forward
http://codefluency.rubyforge.org/fast_forward
Bruce Williams

== DESCRIPTION:

fast_forward is a small library designed to do two things:
* Allow easy delegation of all missing methods to an accessor/instance variable
* Generate methods on-the-fly after first invocation of a delegated method to
eliminate the need to search the object's ancestors and use method_missing
on subsequent invocations

== FEATURES/PROBLEMS:

== SYNOPSIS:

To forward all missing methods to an object, use the <tt>fast_forward_to</tt> class method, as in this example:

class Foo
def some_foo_method
"Hello"
end
end

class Bar
fast_forward_to :my_foo
attr_reader :my_foo
def initialize
@my_foo = Foo.new
end
end

Now, if I create a <tt>Bar</tt> instance, I can call <tt>Foo#some_foo_method</tt> transparently using <tt>Bar#some_foo_method</tt>:

bar = Bar.new
bar.some_foo_method
=> "Hello"

Note I could have also set the forwarding in this example using an instance variable instead of the accessor:

class Bar
fast_forward_to :@my_foo
# the initialize, etc
end

... and it would have worked the same.

The cool feature with this setup is the fact that, one you call a method that gets delegated once on an object, a method to do the delegation is added to the object so performance is better in subsequent invocations:

bar = Bar.new
bar.respond_to?(:some_foo_method)
=> false
bar.some_foo_method
=> "Hello"
bar.respond_to?(:some_foo_method)
=> true

If the target of <tt>fast_forward_to</tt> is <tt>nil</tt>, a FastForwarding::DelegationToNilError will be raised any time a method that would use the delegation is invoked.

== REQUIREMENTS:

* hoe

== INSTALL:

* sudo gem install

== LICENSE:

(The MIT License)

Copyright (c) 2007 Bruce Williams

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.