From 1383445ed09503db844b900b34e8f227bce6dc73 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 8 Sep 2012 08:40:17 -0300 Subject: Refactor some date helpers to use merge! Also just set the hash value instead of merging when it's only one key. --- actionpack/lib/action_view/helpers/date_helper.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 795440cacc..387dfeab17 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -904,10 +904,13 @@ module ActionView # # ..." def build_options(selected, options = {}) + options = { + leading_zeros: true, ampm: false, use_two_digit_numbers: false + }.merge!(options) + start = options.delete(:start) || 0 stop = options.delete(:end) || 59 step = options.delete(:step) || 1 - options.reverse_merge!({:leading_zeros => true, :ampm => false, :use_two_digit_numbers => false}) leading_zeros = options.delete(:leading_zeros) select_options = [] @@ -919,6 +922,7 @@ module ActionView text = options[:ampm] ? AMPM_TRANSLATION[i] : text select_options << content_tag(:option, text, tag_options) end + (select_options.join("\n") + "\n").html_safe end @@ -931,8 +935,8 @@ module ActionView select_options = { :id => input_id_from_type(type), :name => input_name_from_type(type) - }.merge(@html_options) - select_options.merge!(:disabled => 'disabled') if @options[:disabled] + }.merge!(@html_options) + select_options[:disabled] = 'disabled' if @options[:disabled] select_html = "\n" select_html << content_tag(:option, '', :value => '') + "\n" if @options[:include_blank] @@ -968,8 +972,8 @@ module ActionView :id => input_id_from_type(type), :name => input_name_from_type(type), :value => value - }.merge(@html_options.slice(:disabled)) - select_options.merge!(:disabled => 'disabled') if @options[:disabled] + }.merge!(@html_options.slice(:disabled)) + select_options[:disabled] = 'disabled' if @options[:disabled] tag(:input, select_options) + "\n".html_safe end -- cgit v1.2.3