Ruby's private
keyword might do a lot less than you think.
"private" does not apply to class methods defined on self
This does not make anything private:
class Foo
private
def self.foo
'foo'
end
end
You need to use private_class_method
instead:
class Foo
def self.foo
'foo'
end
private_class_method :foo
end
"private" does not apply to define_method
This does not make anything private:
class Foo
private
define_method :foo do
'foo'
end
end
You need to use private
with an argument instead:
class Foo
define_method :foo do
'foo'
end
private :foo
end
Posted by Henning Koch to makandra dev (2013-08-20 15:43)