Sha256: d6c6e8cdd53b69733fa9ebd11faa4d18b4c4a90ac28501a621ddb6c084f7abad
Contents?: true
Size: 991 Bytes
Versions: 40
Compression:
Stored size: 991 Bytes
Contents
# frozen_string_literal: true module FinApps module Utils module QueryBuilder def build_query_path(root_url, params) filter_obj = build_filter(params) filter = "filter=#{ERB::Util.url_encode(filter_obj.to_json)}" unless filter_obj.empty? query_join(root_url, [page(params), requested(params), sort(params), filter]) end private def page(params) "page=#{params[:page].to_i}" if params[:page] end def requested(params) "requested=#{params[:requested].to_i}" if params[:requested] end def sort(params) "sort=#{ERB::Util.url_encode(params[:sort])}" if params[:sort] end def query_join(root_url, params_array) query_string = params_array.compact.join('&') [root_url, query_string].reject(&:empty?).join('?') end def build_filter(_params) # stub, to be overwritten by classes that include this module {} end end end end
Version data entries
40 entries across 40 versions & 1 rubygems