What are Object :: private and Object :: public in Ruby?

What are these methods and how bad is it to redefine them?

irb(main):001:0> Object::respond_to?('private', true) => true irb(main):002:0> Object::respond_to?('public', true) => true 

The problem occurs in Rails when trying to define a scope named private or public for a model. Due to a bug fix for https://rails.lighthouseapp.com/projects/8994/tickets/4167-activerecord-named_scope-using-columns-as-the-name-is-buggered now there are a lot of warnings like:

 Creating scope :public. Overwriting existing method MyModel.public. 
+7
source share
1 answer

The public and private methods are actually ruby ​​access modifiers.

Basically, when you do this:

 class Example public def something end private def something_else end end 

The keywords public and private are not really keywords; they are method calls. I am sure that you should not overestimate them, so I would name the areas in some other way.

+6
source

All Articles