Sha256: ca4aba4d7db02db6477147ba60e07620fea01b49c1a420bda9cece3c64825bfa
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
# encoding: utf-8 module Assertion # 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 # class Inversion < Base # @!scope class # @!method new(assertion) # Creates the inversion for the selected assertion object # # @param [Assertion::Base] assertion The assertion being inverted # # @return [Assertion::Inversion] # @private def initialize(assertion) @assertion = assertion IceNine.deep_freeze(self) end # @!attribute [r] assertion # # @return [Assertion::Base] The assertion being inverted # attr_reader :assertion # The translated message describing the state of assertion # # @param [Boolean] state # # @return [String] # def message(state = nil) assertion.message !state end # Checks the current state of the assertion # # @return [Boolean] # def check !assertion.check end end # class Inversion end # module Assertion
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
assertion-0.2.5 | lib/assertion/inversion.rb |
assertion-0.2.4 | lib/assertion/inversion.rb |
assertion-0.2.3 | lib/assertion/inversion.rb |
assertion-0.2.2 | lib/assertion/inversion.rb |