Sha256: b37da1c99b46764eacf4c34065227ea60e7e6e36599e5fd15aaa05cabd7a8355

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

module Policy

  module Base

    # Negation of given policy
    #
    # It is invalid when given policy is valid.
    # Doesn't add any {#errors}.
    #
    # @example (see #valid?)
    #
    # @api private
    class Not < Node

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

      # Checks whether negated policy is invalid
      #
      # @example
      #   negation = Policy::Base::Not.new(some_policy)
      #   some_policy.valid? # => true
      #   negation.valid?    # => false
      #
      # @return [Boolean]
      def valid?
        super { return true if any_invalid? }
      end

    end # class Not

  end # module Base

end # module Policy

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
policy-2.0.0 lib/policy/base/not.rb