Created
September 9, 2013 13:57
-
-
Save mbj/6495922 to your computer and use it in GitHub Desktop.
protected class methods in ruby
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
class Foo | |
def self.bar | |
:baz | |
end | |
end | |
Foo.bar # => :baz, public | |
class Foo | |
class << self | |
protected :bar | |
end | |
end | |
Foo.bar # raises exception | |
class Foo | |
bar # works | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment