Ruby Forum Ruby-core > Any reason for having no module exclusion functionality in Ruby

Posted by Pit Capitain (Guest)
on 23.04.2008 21:51
(Received via mailing list)
Hi all, I'm forwarding the following message for Yurii, who seems to
have problems joining ruby-core. The current implementation can be
found here:

http://github.com/yrashk/rbmodexcl/tree/master

Regards,
Pit

---------- Forwarded message ----------
From: Yurii Rashkovskii <yrashk@gmail.com>
Date: 2008/4/22
Subject: Any reason for having no module exclusion functionality in R
To: ruby-talk ML <ruby-talk@ruby-lang.org>


Hello,

 May be I am missing something (since I am not MRI hacker), but why
 there is no module exclusion functionality — i.e. you can extend
 object with module, but can't reverse this operation? Any specific
 reason for this decision?

 I've just sketched simplistic implementation for this kind of
 functionality (http://pastie.org/185000) and really wondering why
 there is no such stuff in MRI.

 Again, am I missing something?

 Yurii.
 --
 Posted via http://www.ruby-forum.com/.
Posted by Yehuda Katz (wycats)
on 23.04.2008 23:16
(Received via mailing list)
+1.

Being able to unextend modules would make it possible to temporarily
give methods to an object that were easily removable. I've had a
number of use-cases for it in the past few months.

-- Yehuda
Posted by Kurt Stephens (Guest)
on 24.04.2008 07:23
(Received via mailing list)
Yehuda Katz wrote:
> +1.
> 
> Being able to unextend modules would make it possible to temporarily
> give methods to an object that were easily removable. I've had a number
> of use-cases for it in the past few months.
> 
> -- Yehuda

+1

We do something similar when testing legacy code that is difficult to
decouple.  We have an DSL object that can redefine methods before a
block, yields to a block and then restores the methods after the block
completes.

It would be so much cleaner if we could just extended and unextend.  It
would also be nice to do the same with include: uninclude?

-- Kurt Stephens