# Dynamic Modules

**URL:** <https://www.ruby-forum.com/t/dynamic-modules/75492>\
**Category:** Ruby\
**Created:** [November 10, 2006, 9:31am UTC](https://www.ruby-forum.com/t/dynamic-modules/75492 "2006-11-10T09:31:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sur\_max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47774/32.png) [@sur\_max](https://www.ruby-forum.com/u/sur_max)\
**Post date:** [November 10, 2006, 9:31am UTC](https://www.ruby-forum.com/t/dynamic-modules/75492/1 "2006-11-10T09:31:36Z")

</div>

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

> **[Ajax on Rails](https://ajaxonrails.wordpress.com)**
>
> geeks redefined

---

<div class="post-metadata">

**Author:** ![sur\_max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47774/32.png) [@sur\_max](https://www.ruby-forum.com/u/sur_max)\
**Post date:** [November 10, 2006, 1:02pm UTC](https://www.ruby-forum.com/t/dynamic-modules/75492/2 "2006-11-10T13:02:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sur\_max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47774/32.png) [@sur\_max](https://www.ruby-forum.com/u/sur_max)\
**Post date:** [November 10, 2006, 1:08pm UTC](https://www.ruby-forum.com/t/dynamic-modules/75492/3 "2006-11-10T13:08:05Z")

</div>

Thanx Greg !!
