Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the opposite of Ruby's include?

If I have a class instance, containing several included modules, can I dynamically un-include a specific module (In order to replace it)?

Thanks.

like image 497
QAZ Avatar asked Jan 18 '10 18:01

QAZ


People also ask

What is include in Ruby?

include? is a String class method in Ruby which is used to return true if the given string contains the given string or character.

What is include and extend in Ruby?

In simple words, the difference between include and extend is that 'include' is for adding methods only to an instance of a class and 'extend' is for adding methods to the class but not to its instance. Example : # Ruby program of Include and Extend.

What are Enumerable in Ruby?

Enumeration refers to traversing over objects. In Ruby, we call an object enumerable when it describes a set of items and a method to loop over each of them.

How does Ruby require work?

In Ruby, the require method is used to load another file and execute all its statements. This serves to import all class and method definitions in the file.


1 Answers

No. You can't un-include a mixin in the Ruby Language. On some Ruby Implementations you can do it by writing an implementation specific extension in C or Java (or even Ruby in the case of Rubinius), though.

like image 134
Jörg W Mittag Avatar answered Oct 15 '22 02:10

Jörg W Mittag