Skip to content

Instantly share code, notes, and snippets.

@tisba
Created August 25, 2013 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tisba/6334284 to your computer and use it in GitHub Desktop.
Save tisba/6334284 to your computer and use it in GitHub Desktop.
class A
class << self
protected
def protected_class_method
puts "I'm a protected class method! Called by #{caller.first}"
end
end
end
class B < A
protected_class_method
end
A.protected_class_method
# I'm a protected class method! Called by method_accessability.rb:11:in `<class:B>'
# method_accessability.rb:16:in `<main>': protected method `protected_class_method' called for A:Class (NoMethodError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment