lib/loquor/api_calls/index.rb in loquor-1.6.0 vs lib/loquor/api_calls/index.rb in loquor-1.7.0

- old
+ new

@@ -25,10 +25,26 @@ @criteria[:fields] ||= [] @criteria[:fields] += value self end + def order(value) + @order = value + self + end + + def per(value) + @per = value + self + end + alias_method :limit, :per + + def page(value) + @page = value + self + end + # Proxy everything to the results so that this this class # transparently acts as an Array. def method_missing(name, *args, &block) results.send(name, *args, &block) end @@ -61,9 +77,13 @@ add_criteria(query_string, key, value) end @clauses.each do |clause| add_clause(query_string, clause) end + + query_string << "per=#{@per}" if @per + query_string << "page=#{@page}" if @page + query_string << "order=#{@order}" if @order "#{klass.path}?#{query_string.join("&")}" end def add_criteria(query_string, key, value)