Created
April 9, 2013 13:03
-
-
Save timonv/5345534 to your computer and use it in GitHub Desktop.
Private class methods in Ruby
This file contains hidden or 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 Person | |
def self.get_name | |
persons_name | |
end | |
def self.persons_name | |
"Sam" | |
end | |
private_class_method :persons_name | |
end | |
puts "Hey, " + Person.get_name # Works fine | |
puts "Hey, " + Person.persons_name # Raises |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or, you can define it in the eigenclass directly.