Class: RSpec::JsonMatchers::Expectations::Core::SingletonExpectation Abstract

Inherits:
RSpec::JsonMatchers::Expectation show all
Extended by:
AbstractClass
Defined in:
lib/rspec/json_matchers/expectations/core.rb

Overview

This class is abstract.

This class MUST be used after being inherited Subclasses will have a constant INSTANCE storing the only instance of that class

Note:

This class assumed descendants to NOT override SingletonExpectation.inherited or call super if overridden Otherwise the constant INSTANCE won’t work

Note:

The constant INSTANCE will be referred with namespace, which eliminates the possibility of using parent class constant

Note:

Pattern comes from gem rspec-mocks

Class Method Summary collapse

Methods inherited from RSpec::JsonMatchers::Expectation

build, build_many, #expect?

Class Method Details

.inherited(subclass) ⇒ Object



37
38
39
# File 'lib/rspec/json_matchers/expectations/core.rb', line 37

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