On Wed, Jan 5, 2011 at 2:27 PM, Konrad K. <konrad.krol89 / gmail.com> wrote:
> You're right, thanks for explanation ;)
>
> I decided to rename method in Parent1 from initialize to initializeP and
> define initialize method in Child which calls super and initializeP, now
> everything works fine.

IMHO this is a superior approach: define a method initialize for all
modules with signature (*a,&b) - this will integrate will *every*
inheritance chain and nicely play with all classes.  So you can mix it
in into several different inheritance hierarchies.

module Parent1
  def initialize(*a,&b)
    super
    @loc1 = 1
    @loc2 = 2
  end
end

module Parent2
  def initialize(*a,&b)
    super
    @loc3 = 3
    @loc4 = 4
  end
end

class Child
  include Parent1
end

p Child.new.instance_variables

class Child
  include Parent2
end

p Child.new.instance_variables

class Child
  def initialize
    super
    @loc5 = 5
  end
end

p Child.new.instance_variables

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/