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

Version Path
bogus-0.1.7 lib/bogus/fakes/constructor_methods.rb
bogus-0.1.6 lib/bogus/fakes/constructor_methods.rb
bogus-0.1.5 lib/bogus/fakes/constructor_methods.rb
bogus-0.1.4 lib/bogus/fakes/constructor_methods.rb
bogus-0.1.3 lib/bogus/constructor_methods.rb
bogus-0.1.2 lib/bogus/constructor_methods.rb
bogus-0.1.1 lib/bogus/constructor_methods.rb
bogus-0.1.0 lib/bogus/constructor_methods.rb