123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Mocks::ArgumentMatchers::SingletonMatcher Private

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
RSpec::Mocks::ArgumentMatchers::AnyArgMatcher, RSpec::Mocks::ArgumentMatchers::AnyArgsMatcher, RSpec::Mocks::ArgumentMatchers::BooleanMatcher, RSpec::Mocks::ArgumentMatchers::NoArgsMatcher
Inherits: Object
Defined in: rspec-mocks/lib/rspec/mocks/argument_matchers.rb

Overview

Intended to be subclassed by stateless, immutable argument matchers. Provides a ‘<klass name>::INSTANCE` constant for accessing a global singleton instance of the matcher. There is no need to construct multiple instance since there is no state. It also facilities the special case logic we need for some of these matchers, by making it easy to do comparisons like: `[klass::INSTANCE] == args` rather than `args.count == 1 && klass === args.first`.

Class Method Summary

Class Method Details

.inherited(subklass)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 146

def self.inherited(subklass)
  subklass.const_set(:INSTANCE, subklass.send(:new))
end