lib/loquor/api_calls/index.rb in loquor-0.2.0 vs lib/loquor/api_calls/index.rb in loquor-0.3.0

- old
+ new

@@ -1,12 +1,12 @@ module Loquor class ApiCall::Index < ApiCall attr_reader :criteria - def initialize(path) - super(path) + def initialize(klass) + super(klass) @criteria = {} end def where(value) value.each do |key, value| @@ -26,21 +26,21 @@ per = 200 results = [] begin results = Loquor.get("#{generate_url}&page=#{page}&per=#{per}") results.each do |result| - yield Representation.new(result) + yield klass.new(result) end page += 1 end while(results.size == per) end private def results if @results.nil? - @results = Loquor.get(generate_url).map {|obj| Representation.new(obj)} + @results = Loquor.get(generate_url).map {|obj| klass.new(obj)} end @results end def generate_url @@ -51,9 +51,9 @@ "#{key}=[#{URI.encode(value.join(","))}]" else raise LoquorError.new("Filter values must be strings or arrays.") end }.join("&") - "#{@path}?#{query_string}" + "#{klass.path}?#{query_string}" end end end