# encoding: utf-8 module Policy module Base # Composition of two policies # # The policy is valid if one of its parts is valid, while another is not. # {#valid?} method picks errors from its parts in case both are invalid. # # @example (see #valid?) # # @api private class Xor < Node # Checks if there is both valid and invalid parts are present # # Mutates the policy by adding {#errors} if all parts are invalid. # Doesn't add {#errors} if any part is valid. # # @example # first.valid? # => false # second.valid? # => false # # composition = Policy::Base::Xor.new(first, second) # composition.valid? # => false # composition.errors.empty? # => false # # @return [Boolean] def valid? super { return true if any_valid? && any_invalid? } end end # class Xor end # module Base end # module Policy