Sha256: b3ebc303d20ef992e5a29240bdc97163dfd3eb10508f81e3db1310335cc76bf3

Contents?: true

Size: 886 Bytes

Versions: 34

Compression:

Stored size: 886 Bytes

Contents

require 'mocha/class_method'

module Mocha

  class InstanceMethod < ClassMethod

    def hide_original_method
      super if singleton_method?(method)
    end

    def restore_original_method
      super if singleton_method?(hidden_method)
    end

    def method_exists?(method)
      return true if stubbee.public_methods(false).include?(method)
      return true if stubbee.protected_methods(false).include?(method)
      return true if stubbee.private_methods(false).include?(method)
      return false
    end

    def singleton_method?(method)
      __metaclass__ = stubbee.__metaclass__
      return true if __metaclass__.public_instance_methods(false).include?(method)
      return true if __metaclass__.protected_instance_methods(false).include?(method)
      return true if __metaclass__.private_instance_methods(false).include?(method)
      return false
    end

  end

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/lib/mocha/instance_method.rb
challah-0.9.1.beta.3 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
devise_sociable-0.1.0 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.9.1.beta vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.9.0 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.6.2 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.6.1 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.6.1 vendor/bundle/gems/mocha-0.10.3/lib/mocha/instance_method.rb
challah-0.6.0 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.6.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/instance_method.rb
challah-0.5.4 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.5.4 vendor/bundle/gems/mocha-0.10.3/lib/mocha/instance_method.rb
challah-0.5.3 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.5.3 vendor/bundle/gems/mocha-0.10.3/lib/mocha/instance_method.rb
challah-0.5.2 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
challah-0.5.2 vendor/bundle/gems/mocha-0.10.3/lib/mocha/instance_method.rb
challah-0.5.1 vendor/bundle/gems/mocha-0.10.5/lib/mocha/instance_method.rb
mocha-0.10.5 lib/mocha/instance_method.rb
challah-0.5.0 vendor/bundle/gems/mocha-0.10.3/lib/mocha/instance_method.rb
mocha-0.10.4 lib/mocha/instance_method.rb