lib/cfoundry/v2/base.rb in cfoundry-4.3.2.rc1 vs lib/cfoundry/v2/base.rb in cfoundry-4.3.3

- old
+ new

@@ -34,10 +34,11 @@ end def files(guid, instance, *path) get("v2", "apps", guid, "instances", instance, "files", *path) end + alias :file :files def stream_file(guid, instance, *path, &blk) path_and_options = path + [{:return_response => true, :follow_redirects => false}] redirect = get("v2", "apps", guid, "instances", instance, "files", *path_and_options) @@ -66,17 +67,23 @@ :content => :json, :payload => diff, :return_response => true) end - def all_pages(paginated) - payload = paginated[:resources] + def for_each(paginated, &block) + paginated[:resources].each &block while next_page = paginated[:next_url] paginated = get(next_page, :accept => :json) - payload += paginated[:resources] + paginated[:resources].each &block end + end + def all_pages(paginated) + payload = [] + for_each(paginated) do |resource| + payload << resource + end payload end end end