diff options
author | zzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-23 21:46:43 +0000 |
---|---|---|
committer | zzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-23 21:46:43 +0000 |
commit | 20442b9c4496ee2f0f988f3a58917259e959ea0e () | |
tree | 85826b4ff04f951fdc7513fd91cd1c4721d8e32e | |
parent | b8b26d05cef49eb671ba5b69895d8987a6275c3a (diff) |
reapply r40839 [Fixes GH-316]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/forwardable.rb | 38 |
1 files changed, 24 insertions, 14 deletions
@@ -19,30 +19,40 @@ # #record_number(), which simply calls #[] on the <tt>@records</tt> # array, like this: # # class RecordCollection # extend Forwardable # def_delegator :@records, :[], :record_number # end # # Further, if you wish to provide the methods #size, #<<, and #map, # all of which delegate to @records, this is how you can do it: # -# class RecordCollection -# # extend Forwardable, but we did that above # def_delegators :@records, :size, :<<, :map # end -# f = Foo.new -# f.printf ... -# f.gets -# f.content_at(1) -# -# If the object isn't a Module and Class, You can too extend Forwardable -# module. -# -# printer = String.new -# printer.extend Forwardable # prepare object for delegation -# printer.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts() -# printer.puts "Howdy!" # # == Another example # |