Dynamic Modules

Hi,

We can dynamically include a module in a class as...

class A

  module B
    def method_of_b
    end
  end

end

a = A.new
a.class.send :include, B

Is there any way to remove the dynamically included module from a class.

sur

} We can dynamically include a module in a class as...
[...]
} a = A.new
} a.class.send :include, B
}
} Is there any way to remove the dynamically included module from a class.

In short, no. The language does not allow removing mixins any more than it
allows removing a class's superclass. Individual methods can be removed,
however, using undef or remove_method.

} sur
--Greg

···

On Fri, Nov 10, 2006 at 05:23:14PM +0900, sur max wrote:

Thanx Greg !!

···

On 11/10/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:

On Fri, Nov 10, 2006 at 05:23:14PM +0900, sur max wrote:
} We can dynamically include a module in a class as...
[...]
} a = A.new
} a.class.send :include, B
}
} Is there any way to remove the dynamically included module from a class.

In short, no. The language does not allow removing mixins any more than it
allows removing a class's superclass. Individual methods can be removed,
however, using undef or remove_method.

} sur
--Greg

--
sur