Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/reincarnation.rb
Instance Method Summary collapse
- #bases ⇒ Object
- #bury ⇒ Object
- #included(base) ⇒ Object
- #name_without_namespace ⇒ Object
- #poke_bases(m) ⇒ Object
- #reincarnate ⇒ Object
Instance Method Details
#bases ⇒ Object
8 9 10 |
# File 'lib/reincarnation.rb', line 8 def bases @bases ||= [] end |
#bury ⇒ Object
25 26 27 |
# File 'lib/reincarnation.rb', line 25 def bury parent.__send__(:remove_const, name_without_namespace) end |
#included(base) ⇒ Object
4 5 6 |
# File 'lib/reincarnation.rb', line 4 def included(base) bases << base end |
#name_without_namespace ⇒ Object
21 22 23 |
# File 'lib/reincarnation.rb', line 21 def name_without_namespace name.gsub(/.*::/, '') end |
#poke_bases(m) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/reincarnation.rb', line 12 def poke_bases(m) bases.each do |b| b.module_eval do include(m) poke_bases(m) end end end |
#reincarnate ⇒ Object
29 30 31 32 33 34 |
# File 'lib/reincarnation.rb', line 29 def reincarnate buried = bury reborn = parent.const_set(name_without_namespace, Module.new) poke_bases(reborn) reborn.module_eval { include buried } end |