Return all links if link_class is not provided. Add docs.
authorTom Clegg <tom@curoverse.com>
Fri, 2 May 2014 23:45:16 +0000 (19:45 -0400)
committerTom Clegg <tom@curoverse.com>
Fri, 2 May 2014 23:45:16 +0000 (19:45 -0400)
apps/workbench/app/models/arvados_resource_list.rb

index f0a164188a676ab5ebd2725940c96511ab0cbc15..258aa44e2e2e8d0c5ec90515a108e6c5ed74a455 100644 (file)
@@ -138,7 +138,11 @@ class ArvadosResourceList
     results.links if results.respond_to? :links
   end
 
-  def links_for item_or_uuid, link_class=nil
+  # Return links provided with API response that point to the
+  # specified object, and have the specified link_class. If link_class
+  # is false or omitted, return all links pointing to the specified
+  # object.
+  def links_for item_or_uuid, link_class=false
     return [] if !result_links
     unless @links_for_uuid
       @links_for_uuid = {}
@@ -155,7 +159,7 @@ class ArvadosResourceList
       uuid = item_or_uuid
     end
     (@links_for_uuid[uuid] || []).select do |link|
-      link.link_class == link_class
+      link_class == false or link.link_class == link_class
     end
   end