Created
August 9, 2008 19:45
-
-
Save wycats/4702 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
class Foo | |
private | |
def bar | |
"Hey" | |
end | |
protected | |
def baz | |
"HeyHey" | |
end | |
end | |
class Bar < Foo | |
def call_bar | |
bar | |
end | |
def call_bar_proxy | |
Foo.new.bar | |
end | |
def call_baz | |
baz | |
end | |
def call_baz_proxy | |
Foo.new.baz | |
end | |
end | |
p Bar.new.call_bar | |
p Bar.new.call_baz | |
p Bar.new.call_baz_proxy | |
p Bar.new.call_bar_proxy | |
# "Hey" | |
# "HeyHey" | |
# "HeyHey" | |
# experimentation/experiments/protected.rb:19:in `call_bar_proxy': private method `bar' called for #<Foo:0x28780> (NoMethodError) | |
# from experimentation/experiments/protected.rb:34 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment