Sha256: 0d1c994d3adf6aa70a80ec66d1dae49964f5d03e51194bbef884d20fd8bf9dfd

Contents?: true

Size: 332 Bytes

Versions: 18

Compression:

Stored size: 332 Bytes

Contents

module RSpecCandy
  module Helpers
    module DisposableCopy

      def disposable_copy(&body)
        this = self
        copy = Class.new(self)
        copy.singleton_class.send(:define_method, :name) { this.name }
        copy.class_eval(&body) if body
        copy
      end

      Class.send(:include, self)

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rspec_candy-0.5.1 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.5.0 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.4.1 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.4.0 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.3.1 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.3.0 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.10 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.9 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.8 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.7 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.6 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.5 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.4 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.3 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.2 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.1 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.2.0 lib/rspec_candy/helpers/disposable_copy.rb
rspec_candy-0.1.2 lib/rspec_candy/helpers/disposable_copy.rb