module Solr4R::RequestUriExtension
Attributes
params[RW]
Public Instance Methods
with_params(params)
click to toggle source
# File lib/solr4r/uri_extension.rb, line 41 def with_params(params) self.params, query = params, [self.query].compact params.each { |key, value| query_pairs(key, value).each { |k, v| query << "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" } } self.query = query.join('&') unless query.empty? self end
Private Instance Methods
query_pairs(key, value, pairs = [])
click to toggle source
# File lib/solr4r/uri_extension.rb, line 55 def query_pairs(key, value, pairs = []) if value.is_a?(Hash) kv = value.fetch(vk = :_, true) and pairs << [key, kv] value.each { |sub, val| query_pairs("#{key}.#{sub}", val, pairs) unless sub == vk } else Array(value).each { |val| pairs << [key, val] unless val.nil? } end pairs end