From 3d5359511291d493f7aa4852b815b96b4f66066f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 14 Mar 2014 10:57:46 -0300 Subject: [PATCH] Store the component on the instance We already own the component so we don't need to ask for it again --- lib/simple_form/wrappers/single.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/simple_form/wrappers/single.rb b/lib/simple_form/wrappers/single.rb index 77a6daf3..bc5e82c1 100644 --- a/lib/simple_form/wrappers/single.rb +++ b/lib/simple_form/wrappers/single.rb @@ -3,23 +3,21 @@ module SimpleForm # `Single` is an optimization for a wrapper that has only one component. class Single < Many def initialize(name, wrapper_options = {}, options = {}) - super(name, [Leaf.new(name, options)], wrapper_options) + @component = Leaf.new(name, options) + + super(name, [@component], wrapper_options) end def render(input) options = input.options if options[namespace] != false - content = component.render(input) + content = @component.render(input) wrap(input, options, content) if content end end private - def component - components.first - end - def html_options(options) [:label, :input].include?(namespace) ? {} : super end