Sha256: 6575c5a678bdcf950a752fd108fe14a6a1508b363086010955b67e428c817048

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

# encoding: utf-8

module Policy

  module Base

    # Composition of two policies
    #
    # The policy is valid if any of its parts is valid.
    # {#valid?} method picks errors from its parts in case both are invalid.
    #
    # @example (see #valid?)
    #
    # @api private
    class Or < Node

      # Checks whether any part of composition is valid
      #
      # Mutates the policy by adding {#errors} in case all parts are invalid.
      # Doesn't add {#errors} if any policy is valid.
      #
      # @example
      #   first.valid?  # => true
      #   second.valid? # => false
      #
      #   composition = Policy::Base::Or.new(first, second)
      #   composition.valid?        # => true
      #   composition.errors.empty? # => true
      #
      # @return [Boolean]
      def valid?
        super { return true if any_valid? }
      end

    end # class Or

  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/or.rb