lib/cfoundry/v2/base.rb in cfoundry-0.3.7 vs lib/cfoundry/v2/base.rb in cfoundry-0.3.8
- old
+ new
@@ -72,20 +72,25 @@
define_method(:"update_#{obj}") do |guid, payload|
put(payload, "v2", plural, guid, :json => :json)
end
define_method(plural) do |*args|
- depth, query = args
- depth ||= 1
+ get("v2", plural, nil => :json, :params => params_from(args))
+ end
+ end
- params = { :"inline-relations-depth" => depth }
- if query
- params[:q] = "#{query.keys.first}:#{query.values.first}"
- end
+ def params_from(args)
+ depth, query = args
+ depth ||= 1
- get("v2", plural, nil => :json, :params => params)
+ params = { :"inline-relations-depth" => depth }
+
+ if query
+ params[:q] = "#{query.keys.first}:#{query.values.first}"
end
+
+ params
end
private
def handle_response(response, accept)