lib/cfoundry/v2/base.rb in cfoundry-0.3.38 vs lib/cfoundry/v2/base.rb in cfoundry-0.3.39
- old
+ new
@@ -66,12 +66,14 @@
define_method(:"update_#{obj}") do |guid, payload|
put(payload, "v2", plural, guid, :json => :json)
end
define_method(plural) do |*args|
- get("v2", plural, nil => :json, :params => params_from(args))
+ all_pages(
+ get("v2", plural, nil => :json, :params => params_from(args)))
end
+
end
def resource_match(fingerprints)
put(fingerprints, "v2", "resource_match", :json => :json)
end
@@ -116,9 +118,20 @@
if query
params[:q] = "#{query.keys.first}:#{query.values.first}"
end
params
+ end
+
+ def all_pages(paginated)
+ payload = paginated[:resources]
+
+ while next_page = paginated[:next_url]
+ paginated = request_path(:get, next_page, nil => :json)
+ payload += paginated[:resources]
+ end
+
+ payload
end
private
def handle_response(response, accept)