Sha256: 430467ea03b1bf9f27f638efb08bf2e143dd13ff02b7da0b8327aaec8c7eb90a

Contents?: true

Size: 771 Bytes

Versions: 8

Compression:

Stored size: 771 Bytes

Contents

module Bogus
  class CopiesMethods
    extend Takes

    takes :makes_substitute_methods,
      :method_copiers,
      :copies_constructor

    def copy(from, into)
      method_copiers.each do |copier|
        copy_methods(from, into, copier)
      end
      copies_constructor.copy(from, into)
    end

    private

    def copy_methods(original_class, copy_class, make_methods)
      original_methods = make_methods.call(original_class)
      copy_methods = make_methods.call(copy_class)

      original_methods.all.each do |name|
        method = original_methods.get(name)
        body = method_as_string(method)
        copy_methods.define(body)
      end
    end

    def method_as_string(method)
      makes_substitute_methods.stringify(method)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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