Created
July 23, 2018 03:23
-
-
Save thorvn/ec93a65e6c8fd49894283073bbab1bac to your computer and use it in GitHub Desktop.
Access control in ruby
This file contains hidden or 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 A | |
protected | |
def protected_a | |
puts "Protected A" | |
end | |
private | |
def private_a | |
puts "Private A" | |
end | |
end | |
class B < A | |
def call_protected_a | |
protected_a | |
end | |
def call_protected_b | |
protected_b | |
end | |
def call_private_a | |
private_a | |
end | |
def call_private_b | |
private_b | |
end | |
def call_protected_a_2 | |
self.protected_a | |
end | |
def call_protected_b_2 | |
self.protected_b | |
end | |
def call_private_a_2 | |
self.private_a | |
end | |
def call_private_b_2 | |
self.private_b | |
end | |
protected | |
def protected_b | |
puts "Protected B" | |
end | |
private | |
def private_b | |
puts "Private B" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment