lib/cfoundry/v2/model.rb in cfoundry-0.3.55 vs lib/cfoundry/v2/model.rb in cfoundry-0.3.56

- old
+ new

@@ -146,36 +146,42 @@ kls = object.to_s.capitalize.gsub(/(.)_(.)/) do $1 + $2.upcase end define_method(plural) { |*args| - if cache = @cache[plural] + depth, query = args + + if !depth && !query && cache = @cache[plural] return cache end - depth, query = args - if @manifest && @manifest[:entity].key?(plural) && !depth objs = @manifest[:entity][plural] if query find_by = query.keys.first find_val = query.values.first objs = objs.select { |o| o[:entity][find_by] == find_val } end - @cache[plural] = + res = objs.collect do |json| @client.send(:"make_#{object}", json) end else - @cache[plural] = + res = @client.send( :"#{plural_object}_from", "/v2/#{object_name}s/#@guid/#{plural}", depth || opts[:depth], query) end + + unless depth || query + @cache[plural] = res + end + + res } define_method(:"#{plural}_url") { manifest[:entity][:"#{plural}_url"] }