Sha256: 38d492172f1f62c7df22aaca1f101ad0b7b67b3de7786e22a9d135661dc885bb
Contents?: true
Size: 654 Bytes
Versions: 8
Compression:
Stored size: 654 Bytes
Contents
class Module # Module returns itself. def to_module self #.dup end end class Class # Creates a new module by copying the methods of the class. #-- # Unfortunately this is not dynamic. So once created changes to # the original class will not propagate. I.e. It's not inheritance # proper --and that'snot possible excecpt by change Ruby source. #++ def to_module new_module = Module.new mod = self ancestors.each do |a| a.methods(false).each do |m| m1st = mod.method(m) new_module.module_eval do define_method( m, &m1st ) end end end new_module end end
Version data entries
8 entries across 8 versions & 1 rubygems