module JMESPath
  # @api private
  module Nodes
    class Or < Node
      def initialize(left, right)
        @left = left
        @right = right
      end

      def visit(value)
        result = @left.visit(value)
        if result.nil? or result.empty?
          @right.visit(value)
        else
          result
        end
      end

      def optimize
        self.class.new(@left.optimize, @right.optimize)
      end
    end
  end
end

module JMESPath
  # @api private
  module Nodes
    class Or < Node
      def initialize(left, right)
        @left = left
        @right = right
      end

      def visit(value)
        result = @left.visit(value)
        if result == false || result.nil? || (result.respond_to?(:empty?) && result.empty?)
          @right.visit(value)
        else
          result
        end
      end

      def optimize
        self.class.new(@left.optimize, @right.optimize)
      end
    end
  end
end

Fix OR expressions where the left side is true
Fix OR expressions where the left side is true

TrueClass does not respond to `#empty?`, which makes `foo || bar` where foo resolves to true fail.
