From c0e196e5758e298dbc1fa7d007ddc12243318c19 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 21 Nov 2010 13:50:36 -0200 Subject: [PATCH] Refactor string input a bit --- lib/simple_form/inputs/string_input.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/simple_form/inputs/string_input.rb b/lib/simple_form/inputs/string_input.rb index 65c092329..ac4be8ec5 100644 --- a/lib/simple_form/inputs/string_input.rb +++ b/lib/simple_form/inputs/string_input.rb @@ -4,13 +4,13 @@ class StringInput < Base def input input_html_options[:size] ||= [limit, SimpleForm.default_input_size].compact.min input_html_options[:maxlength] ||= limit if limit - input_html_options[:type] ||= input_type unless input_type == :string + input_html_options[:type] ||= input_type unless string? @builder.text_field(attribute_name, input_html_options) end def input_html_classes - input_type == :string ? super : super.unshift("string") + string? ? super : super.unshift("string") end protected @@ -22,6 +22,10 @@ def limit def has_placeholder? placeholder_present? end + + def string? + input_type == :string + end end end end