Sha256: adb64938ad02fd1cedcaa5d8e91a5d44ff944d877b082feb84961175041f7af8

Contents?: true

Size: 615 Bytes

Versions: 34

Compression:

Stored size: 615 Bytes

Contents

require 'mocha/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

34 entries across 34 versions & 10 rubygems

Version Path
floehopper-mocha-0.9.3.20081220175348 test/method_definer.rb
floehopper-mocha-0.9.3.20081230175553 test/method_definer.rb
floehopper-mocha-0.9.4.20090128164727 test/method_definer.rb
floehopper-mocha-0.9.5.20090201123802 test/method_definer.rb
floehopper-mocha-0.9.6.20090629164857 test/method_definer.rb
floehopper-mocha-0.9.6.20090629165308 test/method_definer.rb
floehopper-mocha-0.9.6.20090701111305 test/method_definer.rb
floehopper-mocha-0.9.7.20090701124354 test/method_definer.rb
gsterndale-warrant-0.2.0 test/rails_root/vendor/gems/mocha-0.9.4/test/method_definer.rb
gsterndale-warrant-0.3.0 test/rails_root/vendor/gems/mocha-0.9.4/test/method_definer.rb
jferris-mocha-0.9.5.0.1240002286 test/method_definer.rb
jferris-mocha-0.9.5.0.1240351621 test/method_definer.rb
jferris-mocha-0.9.5.0.1241126838 test/method_definer.rb
jferris-mocha-0.9.7.0.1247796736 test/method_definer.rb
jferris-mocha-0.9.7.20090701124354 test/method_definer.rb
jferris-mocha-0.9.7.20090911190113 test/method_definer.rb
thewoolleyman-mocha-0.9.3.20081219131457 test/method_definer.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/mocha-0.9.12/test/method_definer.rb
mocha-0.9.12 test/method_definer.rb
mocha-0.9.11 test/method_definer.rb