Sha256: cfc17f2cea336bb41acb1213510946f3f00496bb56060aa4283d35e5ba0d486c
Contents?: true
Size: 492 Bytes
Versions: 6
Compression:
Stored size: 492 Bytes
Contents
class Module # Creates a new module by copying the methods of the class. #-- # This is unfortuate. Class#to_module would be mcuh better, # but doesn't look easily possible. Sigh. #++ def singleton_to_module #( include_ancestors=false ) new_module = Module.new klass = self meths = singleton_methods(true) #-= ['included'] meths.each do |m| new_module.class_eval do define_method(m, &(klass.method(m))) end end new_module end end
Version data entries
6 entries across 6 versions & 1 rubygems