From 89e861ebbba08f3a11fdba1b72b4553576ec13df Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 3 Sep 2011 10:08:51 -0300 Subject: [PATCH] Small cleanup in numeric input --- lib/simple_form/inputs/numeric_input.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/simple_form/inputs/numeric_input.rb b/lib/simple_form/inputs/numeric_input.rb index a7537e27..44c19b7e 100644 --- a/lib/simple_form/inputs/numeric_input.rb +++ b/lib/simple_form/inputs/numeric_input.rb @@ -4,10 +4,12 @@ module SimpleForm enable :placeholder def input - input_html_options[:type] ||= "number" if SimpleForm.html5 input_html_options[:size] ||= nil - input_html_options[:step] ||= integer? ? 1 : "any" if SimpleForm.html5 - infer_attributes_from_validations! if SimpleForm.html5 + if SimpleForm.html5 + input_html_options[:type] ||= "number" + input_html_options[:step] ||= integer? ? 1 : "any" + infer_attributes_from_validations! + end @builder.text_field(attribute_name, input_html_options) end @@ -52,9 +54,13 @@ module SimpleForm end def evaluate_validator_option(option) - return option if option.is_a?(Numeric) - return object.send(option) if option.is_a?(Symbol) - return option.call(object) if option.respond_to?(:call) + if option.is_a?(Numeric) + option + elsif option.is_a?(Symbol) + object.send(option) + elsif option.respond_to?(:call) + option.call(object) + end end end end