lib/inquisitio/searcher.rb in inquisitio-1.3.0 vs lib/inquisitio/searcher.rb in inquisitio-1.3.1
- old
+ new
@@ -43,18 +43,18 @@
klasses[klass] ||= []
klasses[klass] << id
end
objs = klasses.map { |klass_name, ids|
- klass_name = klass_name.gsub("_", "::")
+ klass_name = klass_name.gsub('_', '::')
klass = klass_name.constantize
klass.where(id: ids)
}.flatten
results.each do |result|
klass_name = result['data']['type'].first
- klass_name = klass_name.gsub("_", "::")
+ klass_name = klass_name.gsub('_', '::')
id = result['data']['id'].first
record = objs.select { |r|
r.class.name == klass_name && r.id == id.to_i
}.first
@records << record
@@ -67,10 +67,11 @@
clone do |s|
if value.is_a?(Array)
s.params[:criteria] += value
elsif value.is_a?(Hash)
value.each do |k, v|
+ k = k.to_sym
s.params[:filters][k] ||= []
if v.is_a?(Array)
s.params[:filters][k] = v
else
s.params[:filters][k] << v
@@ -144,11 +145,11 @@
if @failed_attempts < Inquisitio.config.max_attempts
Inquisitio.config.logger.error("Retrying search #{@failed_attempts}/#{Inquisitio.config.max_attempts}")
results
else
- raise InquisitioError.new("Exception performing search")
+ raise InquisitioError.new('Exception performing search')
end
end
def search_url
@search_url ||= begin
@@ -169,10 +170,10 @@
)
end
end
def clone
- params_clone = JSON.parse(params.to_json)
+ params_clone = JSON.parse(params.to_json, symbolize_names: true)
symbolised_params = params_clone.inject({}) do |h, (key, value)|
h[key.to_sym] = value
h
end
Searcher.new(symbolised_params) do |s|