Sha256: f0e90ad6af05f7e7a7ed4e427e4b83ccedf096f9eb42063145a075bf678aa600

Contents?: true

Size: 794 Bytes

Versions: 3

Compression:

Stored size: 794 Bytes

Contents

# encoding: utf-8

module Assertion

  module DSL

    # Allows to provide inverter for objects of the current class
    #
    module Inversion

      # 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
      #
      # @example
      #   IsAdult = Assertion.about :name, :age do
      #     age >= 18
      #   end
      #
      #   joe = { name: 'Joe', age: 19 }
      #
      #   IsAdult[joe].valid?     # => true
      #   IsAdult.not[joe].valid? # => false
      #
      # @return [Assertion::Inverter]
      #
      def not
        Inverter.new(self)
      end

    end # module Inversion

  end # module DSL

end # module Assertion

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assertion-0.2.3 lib/assertion/dsl/inversion.rb
assertion-0.2.2 lib/assertion/dsl/inversion.rb
assertion-0.2.1 lib/assertion/dsl/inversion.rb