class Assertion::Inversion

Describes the inversion of the assertion object

The inversion decorates the source assertion switching its message (from falsey to truthy) and reverting its ‘check`.

@example

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

assertion = IsAdult.new
inversion = Inversion.new(assertion)

assertion.call.valid? == inversion.call.invalid? # => true

@api private

Attributes

assertion[R]

@!attribute [r] assertion

@return [Assertion::Base] The assertion being inverted

Public Class Methods

new(assertion) click to toggle source

@private

# File lib/assertion/inversion.rb, line 33
def initialize(assertion)
  @assertion = assertion
  IceNine.deep_freeze(self)
end

Public Instance Methods

check() click to toggle source

Checks the current state of the assertion

@return [Boolean]

# File lib/assertion/inversion.rb, line 58
def check
  !assertion.check
end
message(state = nil) click to toggle source

The translated message describing the state of assertion

@param [Boolean] state

@return [String]

# File lib/assertion/inversion.rb, line 50
def message(state = nil)
  assertion.message !state
end