Skip to content

Instantly share code, notes, and snippets.

@th0j
Created July 23, 2018 03:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save th0j/ec93a65e6c8fd49894283073bbab1bac to your computer and use it in GitHub Desktop.
Access control in ruby
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