Obviously I modified more than the 2 modules.  This is the best you're 
gonna do, cause I don't think extend has anything that can act as a 
"callback," ala append_features

class Object
  alias_method :old_extend,:extend
  def extend(mod)
    include(mod) if self == X
    old_extend(mod)
  end
end

module N
  def foo
    "N#foo"
  end
end

module M
  include N
end

class X
  extend M
end

puts X.new.foo # N#foo

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