Class: Assertion::Inversion Private

Inherits:
Base
  • Object
show all
Defined in:
lib/assertion/inversion.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Describes the inversion of the assertion object

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

Examples:

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

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

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

Constant Summary

Constants included from Messages

Messages::DICTIONARY, Messages::ROOT

Class Attribute Summary collapse

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods inherited from Base

[], #call, #initialize, not

Methods included from Attributes

#attribute, #attributes

Methods included from Messages

#attributes, #message

Constructor Details

This class inherits a constructor from Assertion::Base

Class Attribute Details

.assertionAssertion::Base (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The assertion being inverted.



42
43
44
# File 'lib/assertion/inversion.rb', line 42

def assertion
  @assertion
end

Class Method Details

.checkBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks the current state of the assertion



58
59
60
# File 'lib/assertion/inversion.rb', line 58

def check
  !assertion.check
end

.initialize(assertion) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
# File 'lib/assertion/inversion.rb', line 33

def initialize(assertion)
  @assertion = assertion
  freeze
end

.message(state = nil) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The translated message describing the state of assertion



50
51
52
# File 'lib/assertion/inversion.rb', line 50

def message(state = nil)
  assertion.message !state
end

.new(assertion) ⇒ Assertion::Inversion

Creates the inversion for the selected assertion object



# File 'lib/assertion/inversion.rb', line 24