logo       

ActiveRecord: private versus protected methods: msg#00228

lang.ruby.rails.core

Subject: ActiveRecord: private versus protected methods


Hi,

I'm considering subclassing ActiveRecord::Migrator to enhance the way
it tracks the migration version number of a database. However there's
a hurdle: it has private methods.

Private methods are a major stumbling block for anyone needing to
sub-class something. If the public methods of the class call the
private methods, you can't sub-class without replacing all the private
methods (because otherwise they won't be available in the descendant
class).

A much better approach is to declare methods as 'protected'. That
offers a lot more flexibility:

* The methods are still protected from being called from outside the
class.

* The class can be sub-classed, and it will still work.

Does anyone know: is there a compelling reason for using 'private' in
this case? Are there any core developers listening? Can you make your
methods 'protected' instead of 'private' please?

I really don't want to have to maintain my own fork of
ActiveRecord::Migrator.


Thanks and regards,
Urbanus
http://goldberg.240gl.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core
-~----------~----~----~----~------~----~------~--~---




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise