Created
May 22, 2012 05:38
-
-
Save kachick/2766856 to your computer and use it in GitHub Desktop.
Forwardableで追加されるメソッドってpublicだよねという確認?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby -w | |
| require 'forwardable' | |
| class B | |
| def aaa | |
| puts 'Yeah!' | |
| end | |
| end | |
| class A | |
| extend Forwardable | |
| def initialize | |
| @recv = B.new | |
| end | |
| def_delegators :@recv, :aaa | |
| private :aaa | |
| def ccc | |
| aaa | |
| end | |
| end | |
| a = A.new | |
| a.ccc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment