Project

General

Profile

Feature #11639 ยป 0001-Refactors-documentation-for-Forwardable.patch

sjmog (Sam Morgan), 10/30/2015 02:35 PM

View differences:

lib/forwardable.rb
#
# == Another example
#
# We want to rely on what has come before obviously, but with delegation we can
# take just the methods we need and even rename them as appropriate. In many
# cases this is preferable to inheritance, which gives us the entire old
# interface, even if much of it isn't needed.
# You could use Forwardable as an alternative to inheritance, when you don't want
# to inherit all methods from the superclass. For instance, here is how you might
# add a range of <tt>Array</tt> instance methods to a new class <tt>Queue</tt>:
#
# class Queue
# extend Forwardable
    (1-1/1)