On Jul 22, 2007, at 4:39 PM, Michael Koziarski wrote:

>
> I can buy your argument, but if I do so, there doesn't seem to be a
> need for after_initialize:
>
> def initialize(attrs)
>   do_stuff
>   super
> end

one other nit-pick: it's somewhat archaic and java like to  
__require__ client code to call super, one slip of the keyboard and  
someone is bug finding...

it's much nicer, imho, to relieve the client code from that burden via

class ActionRecord::Base
   def self.new *args, &block
     returning(allocate) do |object|
       object.instance_eval do
          internal_initialize *args, &block  # all real work here
          initialize *args, &block           # default does nothing
       end
     end
   end
end


basically just following the paradigm whereby designing classes that  
a made to be inherited with any work in initialize is less that  
ideal...  food for thought.

cheers.

a @ http://drawohara.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama




--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to