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 = {}
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