Posted over 5 years ago. Visible to the public.

The "private" modifier does not apply to class methods or define_method

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:

Copy
class Foo private def self.foo 'foo' end end

You need to use private_class_method instead:

Copy
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:

Copy
class Foo private define_method :foo do 'foo' end end

You need to use private with an argument instead:

Copy
class Foo define_method :foo do 'foo' end private :foo end

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Henning Koch
Last edit:
about 5 years ago
Keywords:
visibility
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more