Is there any preference over the two methods
below for adding functionality to a class?
If I needed to append some functionality to a
particular method in B, then I think Method 2
would be required so that super could be called.
Choosing method 1 would limit this ability.
However, Method 1 gives me the ability to inherit
from another class and still provide the functionality
of Method 2.
## === METHOD 1 ====
module B
def initialize
# ... do stuff
end
def other_funcs
# ...
end
end#module A
class A
include B
end#class A
or
## === METHOD 2 ====
class B
def initialize
# ... do stuff
end
def other_funcs
# ...
end
end#class B
class A < B
end#class A
=========================================================
Jim Freeze
jim / freeze.org
---------------------------------------------------------
Today is a fine day for Ruby programming.
http://www.freeze.org
=========================================================