|
Re: ActiveRecord: private versus protected methods: msg#00230lang.ruby.rails.core
On 9/27/06, urbanus <urbanus@xxxxxxxxx> wrote: I'm considering subclassing ActiveRecord::Migrator to enhance the way irb(main):005:0> class C; def bar() foo end; def foo() puts 'foo' end; private :foo end => C irb(main):006:0> class D < C; end => nil irb(main):007:0> D.new.foo NoMethodError: private method `foo' called for #<D:0x2aaaab4eab10> from (irb):7 irb(main):008:0> D.new.bar foo => nil A much better approach is to declare methods as 'protected'. That You need protected only if you wish the call the method from a subclass. The inherited public method is not affected. Please bring up specific examples (preferably as Trac tickets) and we will address them. jeremy --~--~---------~--~----~------------~-------~--~----~ 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> |
|---|---|---|
| Previous by Date: | Re: ActiveSupport::Multibyte for better Unicode support, Pete Yandell |
|---|---|
| Next by Date: | Re: ActiveRecord: private versus protected methods, urbanus |
| Previous by Thread: | ActiveRecord: private versus protected methods, urbanus |
| Next by Thread: | Re: ActiveRecord: private versus protected methods, urbanus |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |