lib/inquisitio/searcher.rb in inquisitio-1.2.4 vs lib/inquisitio/searcher.rb in inquisitio-1.3.0
- old
+ new
@@ -14,11 +14,12 @@
criteria: [],
filters: {},
per: 10,
page: 1,
returns: [],
- with: {}
+ with: {},
+ sort: {}
}
@failed_attempts = 0
yield(self) if block_given?
end
@@ -107,10 +108,16 @@
clone do |s|
s.params[:with].merge!(value)
end
end
+ def sort(value)
+ clone do |s|
+ s.params[:sort].merge!(value)
+ end
+ end
+
# Proxy everything to the results so that this this class
# transparently acts as an Array.
def method_missing(name, *args, &block)
results.to_a.send(name, *args, &block)
end
@@ -155,9 +162,10 @@
query: params[:criteria],
filters: params[:filters],
arguments: params[:with],
size: params[:per],
start: params[:per] * (params[:page] - 1),
+ sort: params[:sort],
return_fields: return_fields
)
end
end