Module: Assertion::DSL::Inversion

Included in:
Base
Defined in:
lib/assertion/dsl/inversion.rb

Overview

Allows to provide inverter for objects of the current class

Instance Method Summary collapse

Instance Method Details

#notAssertion::Inverter

Initializes the intermediate inverter with ‘new` and `[]` methods

The inverter can be used to initialize the assertion, that describes just the opposite statement to the current one

Examples:

IsAdult = Assertion.about :name, :age do
  age >= 18
end

joe = { name: 'Joe', age: 19 }

IsAdult[joe].valid?     # => true
IsAdult.not[joe].valid? # => false

Returns:



28
29
30
# File 'lib/assertion/dsl/inversion.rb', line 28

def not
  Inverter.new(self)
end