Last active
August 29, 2015 14:25
-
-
Save gvillalta99/02561f781ce672232c38 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
# Testing Ruby's method visibility with Modules | |
module A | |
def public_method | |
puts :public_method | |
end | |
protected | |
def protected_method | |
puts :protected_method | |
end | |
private | |
def private_method | |
puts :private_method | |
end | |
end | |
class B | |
include A | |
def testing_visibility | |
public_method | |
protected_method | |
private_method | |
end | |
end | |
b = B.new | |
b.testing_visibility | |
b.public_method | |
b.protected_method | |
b.private_method | |
# ruby test_visibility.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment