Created
September 15, 2017 10:42
-
-
Save kalorz/2d3839f300d77753a565f4569a263be9 to your computer and use it in GitHub Desktop.
Ruby Gotchas: private self.method (solution)
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 | |
class << self | |
private | |
def bar | |
puts 'Class method called' | |
end | |
end | |
def self.baz | |
puts 'Another class method called' | |
end | |
private_class_method :baz | |
end | |
Foo.bar # => NoMethodError: private method `bar' called for Foo:Class | |
Foo.baz # => NoMethodError: private method `baz' called for Foo:Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment