1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Store the component on the instance

We already own the component so we don't need to ask for it again
This commit is contained in:
Rafael Mendonça França 2014-03-14 10:57:46 -03:00
parent 724dff54d5
commit 3d53595112

View file

@ -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