Sha256: 820299e4ce8daa9dff79ba8dbe744c99ea82e77d87f10ef7a11aab07baf6d353

Contents?: true

Size: 605 Bytes

Versions: 34

Compression:

Stored size: 605 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

34 entries across 29 versions & 3 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.9.1.beta.3 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
devise_sociable-0.1.0 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.9.1.beta vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.9.0 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.6.2 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.6.1 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.6.1 vendor/bundle/gems/mocha-0.10.3/test/method_definer.rb
challah-0.6.0 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.6.0 vendor/bundle/gems/mocha-0.10.3/test/method_definer.rb
challah-0.5.4 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.5.4 vendor/bundle/gems/mocha-0.10.3/test/method_definer.rb
challah-0.5.3 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.5.3 vendor/bundle/gems/mocha-0.10.3/test/method_definer.rb
challah-0.5.2 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
challah-0.5.2 vendor/bundle/gems/mocha-0.10.3/test/method_definer.rb
challah-0.5.1 vendor/bundle/gems/mocha-0.10.5/test/method_definer.rb
mocha-0.10.5 test/method_definer.rb
challah-0.5.0 vendor/bundle/gems/mocha-0.10.3/test/method_definer.rb
mocha-0.10.4 test/method_definer.rb