From 967d4c81ab8bb5e252a37a568d857170c846bd78 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 8 May 2014 15:51:48 +1000 Subject: [PATCH] Cache expensive options_text call --- app/views/spree/api/variants/units_show.v1.rabl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/spree/api/variants/units_show.v1.rabl b/app/views/spree/api/variants/units_show.v1.rabl index 326508bd4a..634213e53f 100644 --- a/app/views/spree/api/variants/units_show.v1.rabl +++ b/app/views/spree/api/variants/units_show.v1.rabl @@ -1,4 +1,9 @@ object @variant attributes :id -node( :unit_text ) { |v| v.product.name + (v.options_text.empty? ? "" : ": " + v.options_text) } + +node( :unit_text ) do |v| + options_text = v.options_text + v.product.name + (options_text.empty? ? "" : ": #{options_text}") +end + node( :unit_value ) { |v| v.unit_value }