Sha256: f30787db905ea980b896ca72225944d4d7b8ac19ddda2eeb8708c85d50fdbba7

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

# encoding: utf-8

module Attestor

  module Policy

    # Negation of a single policy
    #
    # The policy is valid if its only branch is invalid
    #
    # @example (see #validate)
    #
    # @api private
    class Not < Node

      # @!scope class
      # @!method new(policy)
      # Creates the policy negation
      #
      # @param [Array<Policy::Base>] policy
      #
      # @return [Policy::Base::Node]

      # @private
      def initialize(_)
        super
      end

      # Checks whether every policy is valid
      #
      # @example
      #   policy.valid? # => true
      #
      #   composition = Attestor::Policy::Not.new(policy)
      #   composition.validate
      #   # => Policy::InvalidError
      #
      # @return [undefined]
      def validate
        return unless detect(&:valid?)
        super
      end

    end # class And

  end # module Base

end # module Policy

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attestor-1.0.0 lib/attestor/policy/not.rb
attestor-0.4.0 lib/attestor/policy/not.rb