aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2012-02-21 20:32:20 +0300
committerVasiliy Ermolovich <younash@gmail.com>2012-02-21 20:32:20 +0300
commit50cf5f761ddd7030cef463dfdebddfded7c961cd (patch)
treeda5554cb646fc9164064e59ad04048c08b7967d4 /actionpack
parent9dd64f2e0c1b3ce85b503b0f81c50c93f89ffbcd (diff)
downloadrails-50cf5f761ddd7030cef463dfdebddfded7c961cd.tar.gz
rails-50cf5f761ddd7030cef463dfdebddfded7c961cd.tar.bz2
rails-50cf5f761ddd7030cef463dfdebddfded7c961cd.zip
refactor option_text_and_value and option_value_selected? methods
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb13
1 files changed, 3 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 70cc6906cd..f73ca220fb 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -660,11 +660,8 @@ module ActionView
def option_text_and_value(option)
# Options are [text, value] pairs or strings used for both.
- case
- when Array === option
- option = option.reject { |e| Hash === e }
- [option.first, option.last]
- when !option.is_a?(String) && option.respond_to?(:first) && option.respond_to?(:last)
+ if !option.is_a?(String) && option.respond_to?(:first) && option.respond_to?(:last)
+ option = option.reject { |e| Hash === e } if Array === option
[option.first, option.last]
else
[option, option]
@@ -672,11 +669,7 @@ module ActionView
end
def option_value_selected?(value, selected)
- if selected.respond_to?(:include?) && !selected.is_a?(String)
- selected.include? value
- else
- value == selected
- end
+ Array(selected).include? value
end
def extract_selected_and_disabled(selected)