Sha256: 71459ffbb415ff0f56b79d96a5898ab798cb9df8479c3f5478892cae714b4d5d

Contents?: true

Size: 507 Bytes

Versions: 9

Compression:

Stored size: 507 Bytes

Contents

require 'mocha/metaclass'

class Object
  
  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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mocha-0.3.3 test/method_definer.rb
mocha-0.1.2 test/method_definer.rb
mocha-0.2.0 test/method_definer.rb
mocha-0.3.2 test/method_definer.rb
mocha-0.1 test/method_definer.rb
mocha-0.1.1 test/method_definer.rb
mocha-0.2.1 test/method_definer.rb
mocha-0.3.0 test/method_definer.rb
mocha-0.3.1 test/method_definer.rb