Skip to content

Instantly share code, notes, and snippets.

@kalorz
Created September 15, 2017 10:42
Show Gist options
  • Save kalorz/2d3839f300d77753a565f4569a263be9 to your computer and use it in GitHub Desktop.
Save kalorz/2d3839f300d77753a565f4569a263be9 to your computer and use it in GitHub Desktop.
Ruby Gotchas: private self.method (solution)
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