# frozen_string_literal: true module Some class Messages AND_CONJUCTION = :and OR_CONJUCTION = :or DEFAULT_CONJUCTION = AND_CONJUCTION attr_reader :query, :current_conjuction def initialize @query = [] @current_conjuction = AND_CONJUCTION end def or @current_conjuction = OR_CONJUCTION self end def filter(params) query << params.map do |key, value| unless value.is_a? Array [current_conjuction, key, value.to_sym] else [current_conjuction, value.map { |subarg| [OR_CONJUCTION, key, subarg] }] end end self end def query_string end end end