module X
    def self.included(mod)
      define_method ... # define method from here
    end
  end

  module N
    # <- define method to this namespace (N)
    module M
      include X
    end
  end

T.