Method: Module#insert
- Defined in:
- lib/ruby_ext.rb
#insert(new_mod) ⇒ Object
WARNING : This is a dangerous method
It’s like include but changes the order so that the new module is before the older one.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_ext.rb', line 23 def insert(new_mod) new_mod = new_mod.dup old_mod = self mod_name = self.basename new_mod.module_eval do include old_mod end (nesting[-2] || Object).module_eval do remove_const mod_name const_set mod_name, new_mod end end |