Module.include vs. reopening a Module

I am attempting to create a plugin, with some methods in my own module.
These would then be included to various pieces of active record. This
works
fine when including them in classes, but when including them in a
module,
the classes which include that module do not get the methods. These
classes
do however get them when directly reopening the module. Is there any way
around this, or is it best to just reopen the module and define the new
methods?

Here is a stripped down example of the problematic code…

module A
def test
“test”
end
end

class B
include A
end

B.new.test
=> “test”

module C
def test_two
“test_two”
end
end

A.send :include, C

B.new.test_two
NoMethodError: undefined method `test_two’ for #<B:0xa7b8ddbc>

class D
include A
end

D.new.test_two
=> “test_two”

HOWEVER…

module A
def test_two
“test_two_again”
end
end

B.new.test_two
=> “test_two_again”


Mark Van H.
[email protected]
http://lotswholetime.com

On 8/23/06, Mark Van H. [email protected] wrote:

I am attempting to create a plugin, with some methods in my own module.
[snip]

Hi Mark:

I know that what you are trying to do is possible, but I believe since
you are including modules inside modules things get a bit tricky. I
would recommend posting and searching in ruby-talk, as this is really
more of a standard ruby question.