Sha256: d5f453b449abaa79b2d4cb42f1eb8338aa9ae30d5af4b77c85125462c893cc34
Contents?: true
Size: 479 Bytes
Versions: 8
Compression:
Stored size: 479 Bytes
Contents
module Bogus class CopiesConstructor extend Takes takes :method_stringifier, :instance_methods, :class_methods def copy(from, into) return unless from.is_a?(Class) initializer = instance_methods.call(from).get(:initialize) body = body(initializer) class_methods.call(into).define(body) end def body(initializer) body = method_stringifier.stringify(initializer, "super") body.gsub("initialize", "new") end end end
Version data entries
8 entries across 8 versions & 1 rubygems