Skip to content

Instantly share code, notes, and snippets.

@gvillalta99
Last active August 29, 2015 14:25
Show Gist options
  • Save gvillalta99/02561f781ce672232c38 to your computer and use it in GitHub Desktop.
Save gvillalta99/02561f781ce672232c38 to your computer and use it in GitHub Desktop.
# 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