I have a class with N methods. I want to set one of these methods to private. How can I do 开发者_如何学运维this?
class Example
def methodA
end
def methodP
end
private :methodP
end
I like this way:
class Example
def public_method1
end
private def used_by_public_method1
end
def public_method2
end
end
Another option (that I find more confusing):
class Example
def public_method1
end
def public_method2
end
private
def used_by_public_method1
end
# Don't accidentally put public methods down here.
end
精彩评论