Created
April 9, 2014 13:52
-
-
Save miyohide/10273095 to your computer and use it in GitHub Desktop.
This file contains 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
module Hoge1 | |
def hoge1_method | |
puts "public geba" | |
end | |
end | |
module Hoge2 | |
private | |
def hoge2_method | |
puts "private geba" | |
end | |
end | |
class Foo | |
include Hoge1 | |
include Hoge2 | |
def foo_method | |
hoge1_method | |
hoge2_method | |
end | |
def foo_method2 | |
self.hoge1_method | |
self.hoge2_method | |
end | |
end | |
Foo.new.foo_method # => "public geba\nprivate geba" | |
Foo.new.foo_method2 # => これではhoge2_methodがprivateなためエラーと成る |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment