This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
rbmodexcl / rbxmodexcl.rb
| 28209d5f » | yrashk | 2008-05-20 | 1 | class Object | |
| 2 | |||||
| 3 | def unextend(mod) | ||||
| 4 | raise ArgumentError, "Module is expected" unless mod.is_a?(Module) | ||||
| 5 | raise ArgumentError, "unextending Kernel is prohibited" if mod == Kernel | ||||
| 6 | prev = p = metaclass | ||||
| 7 | while p | ||||
| 8 | if (p == mod || (p.respond_to?(:module) && p.module == mod)) | ||||
| 9 | prev.set_superclass(p.direct_superclass) | ||||
| 10 | # remove cache | ||||
| 11 | self.methods.each do |name| | ||||
| 12 | name = self.metaclass.send(:normalize_name,name) | ||||
| 13 | Rubinius::VM.reset_method_cache(name) | ||||
| 14 | end | ||||
| 15 | # | ||||
| 16 | mod.send(:unextended, self) if mod.respond_to?(:unextended) | ||||
| 17 | return self | ||||
| 18 | end | ||||
| 19 | prev = p | ||||
| 20 | p = p.direct_superclass | ||||
| 21 | end | ||||
| 22 | |||||
| 23 | end | ||||
| 24 | |||||
| 25 | def uninclude(mod) | ||||
| 26 | raise ArgumentError, "Module is expected" unless mod.is_a?(Module) | ||||
| 27 | raise ArgumentError, "unincluding Kernel is prohibited" if mod == Kernel | ||||
| 28 | prev = p = self | ||||
| 29 | while p | ||||
| 30 | if (p == mod || (p.respond_to?(:module) && p.module == mod)) | ||||
| 31 | prev.superclass=(p.direct_superclass) | ||||
| 32 | # remove cache | ||||
| 33 | self.methods.each do |name| | ||||
| 34 | name = self.metaclass.send(:normalize_name,name) | ||||
| 35 | Rubinius::VM.reset_method_cache(name) | ||||
| 36 | end | ||||
| 37 | # | ||||
| 38 | mod.send(:unincluded, self) if mod.respond_to?(:unincluded) | ||||
| 39 | return self | ||||
| 40 | end | ||||
| 41 | prev = p | ||||
| 42 | p = p.direct_superclass | ||||
| 43 | end | ||||
| 44 | |||||
| 45 | end | ||||
| 46 | |||||
| 47 | end | ||||
| 48 | |||||







