My base.extend does not extend the base

I want to try out extending a class as explained in

  http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/

(see the section "A Common Idiom"). Note that I'm NOT talking about
Rails. I just want to understand this feature of Ruby better.

I have as a first step created the following example:

module MixTest
  def self.include(base) # Macro. Invoked when this module gets
included.
    base.extend C_Methods # C_Methods contains the class methods to
include
  end
  module C_Methods
    def a_test_method
    end
  end
end

class Test
  include MixTest # Should include a_test_method
  end
end

My undestandig is that

  include MixTest

inside Test should invoke self.include, which in turn should add the
methods defined in MixTest.C_Methods to Test.

However, when executing afterwards

  p Test.respond_to?('a_test_method')

I get 'false'. What did I do wrong?

···

--
Posted via http://www.ruby-forum.com/.

module MixTest
  def self.include(base) # Macro. Invoked when this module gets
included.

self.included

John

John W Higgins wrote in post #1122685:

self.included

Thanks! I just found this too this moment, but it was already too late
to delete this post. Ah, silly me....

Ronald

···

--
Posted via http://www.ruby-forum.com/\.

All your base are belong to us.

You knew it was coming, didn't you? :stuck_out_tongue:

···

On 09/27/2013 07:47 AM, Ronald Fischer wrote:

John W Higgins wrote in post #1122685:

self.included

Thanks! I just found this too this moment, but it was already too late
to delete this post. Ah, silly me....

Ronald