# 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