I
Iñaki Baz Castillo
Hi, I have a class C that includes a module M.
I need that when a C object is created a module M method is runned=20
automatically (without call it from "initialize" method) to fill an object=
=20
attribute. Something as:
=2D--------------------------------------
module M
def module_method
@words << "module_word"
end
end
class C
include C
attr_reader :words
def initialize
@words =3D []
@words << "class_word"
end
end
=2D--------------------------------------
irb> c=3DC.new
irb> c.words
["class_word", "module_word"]
Is it possible without adding "module_method()" in class C initialize metho=
d?
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo
I need that when a C object is created a module M method is runned=20
automatically (without call it from "initialize" method) to fill an object=
=20
attribute. Something as:
=2D--------------------------------------
module M
def module_method
@words << "module_word"
end
end
class C
include C
attr_reader :words
def initialize
@words =3D []
@words << "class_word"
end
end
=2D--------------------------------------
irb> c=3DC.new
irb> c.words
["class_word", "module_word"]
Is it possible without adding "module_method()" in class C initialize metho=
d?
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo