Sha256: 9089ec013e647412043b53d33605450310df7953602d3c80ded1510a22cccfa9

Contents?: true

Size: 573 Bytes

Versions: 4

Compression:

Stored size: 573 Bytes

Contents

module Bogus
  class CopiesClasses
    extend Takes

    takes :copies_methods

    def copy(klass)
      copy_class = Class.new(Bogus::Fake) do
        define_singleton_method(:__copied_class__) do
          klass
        end

        define_singleton_method(:name) do
          klass.name
        end

        define_singleton_method(:to_s) do
          klass.name
        end

        define_singleton_method(:const_missing) do |name|
          klass.const_get(name)
        end
      end

      copies_methods.copy(klass, copy_class)
      copy_class
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bogus-0.1.7 lib/bogus/fakes/copies_classes.rb
bogus-0.1.6 lib/bogus/fakes/copies_classes.rb
bogus-0.1.5 lib/bogus/fakes/copies_classes.rb
bogus-0.1.4 lib/bogus/fakes/copies_classes.rb