From cd2f381154c0ed44385ada53cd184782113d9e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 12 Nov 2013 19:50:14 -0200 Subject: [PATCH] Extract a private method to apply the label_input component options --- lib/simple_form/components/label_input.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/simple_form/components/label_input.rb b/lib/simple_form/components/label_input.rb index e4b63dd8..eaf988af 100644 --- a/lib/simple_form/components/label_input.rb +++ b/lib/simple_form/components/label_input.rb @@ -8,12 +8,21 @@ module SimpleForm end def label_input + apply_label_input_options(options) + + options[:label] == false ? input : (label + input) + end + + private + + # Get the options given to the label_input component and apply to both + # label and input components. + def apply_label_input_options(options) [:input_html, :label_html].each do |key| - if options.has_key? key + if options.has_key?(key) options[key].merge! options.fetch(:label_input_html, {}) end end - options[:label] == false ? input : (label + input) end end end