# encoding: utf-8 module Policy module Base # Composition of two policies # # The policy is valid if both its parts are valid. # {#valid?} method picks errors from its parts in case any is invalid. # # @example (see #valid?) # # @api private class And < Node # Checks whether every policy is valid # # Mutates the policy by adding {#errors} from its invalid part. # # @example # first.valid? # => true # second.valid? # => false # # composition = Policy::Base::And.new(first, second) # composition.valid? # => false # composition.errors == second.errors # => true # # @return [Boolean] def valid? super { return true unless any_invalid? } end end # class And end # module Base end # module Policy