Sha256: 7bf83b45bc74974baa3ddea381140db48209b1fd6522beda5bb65a73a8c05087

Contents?: true

Size: 606 Bytes

Versions: 77

Compression:

Stored size: 606 Bytes

Contents

require 'metaclass'

module Mocha

  module ObjectMethods
    def define_instance_method(method_symbol, &block)
      __metaclass__.send(:define_method, method_symbol, block)
    end

    def replace_instance_method(method_symbol, &block)
      raise "Cannot replace #{method_symbol} as #{self} does not respond to it." unless self.respond_to?(method_symbol)
      define_instance_method(method_symbol, &block)
    end

    def define_instance_accessor(*symbols)
      symbols.each { |symbol| __metaclass__.send(:attr_accessor, symbol) }
    end
  end

end

class Object
  include Mocha::ObjectMethods
end

Version data entries

77 entries across 62 versions & 7 rubygems

Version Path
mocha-1.6.0 test/method_definer.rb
mocha-1.5.0 test/method_definer.rb
mocha-1.4.0 test/method_definer.rb
mocha-1.3.0 test/method_definer.rb
mocha-1.2.1 test/method_definer.rb
mocha-1.2.0 test/method_definer.rb
bourne-1.6.0 test/method_definer.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/method_definer.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/method_definer.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/method_definer.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/method_definer.rb
mocha-1.1.0 test/method_definer.rb
mocha-1.0.0 test/method_definer.rb
mocha-1.0.0.alpha test/method_definer.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/method_definer.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/test/method_definer.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/method_definer.rb
bourne-1.5.0 test/method_definer.rb
mocha-0.14.0 test/method_definer.rb
challah-1.0.0.beta3 vendor/bundle/gems/bourne-1.4.0/test/method_definer.rb