Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small cleanup in numeric input

  • Loading branch information...
commit 89e861ebbba08f3a11fdba1b72b4553576ec13df 1 parent a0a7fb2
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 12 additions and 6 deletions.
  1. +12 −6 lib/simple_form/inputs/numeric_input.rb
View
18 lib/simple_form/inputs/numeric_input.rb
@@ -4,10 +4,12 @@ class NumericInput < Base
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 @@ def find_numericality_validator
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
Please sign in to comment.
Something went wrong with that request. Please try again.