Posted almost 6 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
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Henning Koch
Last edit:
over 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