Skip to content

Instantly share code, notes, and snippets.

@miyohide
Created April 9, 2014 13:52
Show Gist options
  • Save miyohide/10273095 to your computer and use it in GitHub Desktop.
Save miyohide/10273095 to your computer and use it in GitHub Desktop.
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