Avoid extra API lookup to get an object that is already loaded.
authorTom Clegg <tom@curoverse.com>
Sun, 9 Mar 2014 08:20:58 +0000 (04:20 -0400)
committerTom Clegg <tom@curoverse.com>
Sun, 9 Mar 2014 08:20:58 +0000 (04:20 -0400)
apps/workbench/app/helpers/application_helper.rb

index cd8e5279dd0bdf595bbce465c2c9b693c0385a53..2927be8739df409e0c869261ebd11a167a9f6a1f 100644 (file)
@@ -55,11 +55,15 @@ module ApplicationHelper
         link_name = link_uuid
 
         if opts[:friendly_name]
-          begin
-            link_name = resource_class.find(link_uuid).friendly_link_name
-          rescue RuntimeError
-            # If that lookup failed, the link will too. So don't make one.
-            return attrvalue
+          if attrvalue.respond_to? :friendly_link_name
+            link_name = attrvalue.friendly_link_name
+          else
+            begin
+              link_name = resource_class.find(link_uuid).friendly_link_name
+            rescue RuntimeError
+              # If that lookup failed, the link will too. So don't make one.
+              return attrvalue
+            end
           end
         end
         if opts[:with_class_name]