Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor some date helpers to use merge!

Also just set the hash value instead of merging when it's only one key.
  • Loading branch information...
commit 1383445ed09503db844b900b34e8f227bce6dc73 1 parent 0801f6a
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 actionpack/lib/action_view/helpers/date_helper.rb
View
14 actionpack/lib/action_view/helpers/date_helper.rb
@@ -904,10 +904,13 @@ def build_options_and_select(type, selected, options = {})
# <option value="3">3</option>
# <option value="5">5</option>..."
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 @@ def build_options(selected, options = {})
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 @@ def build_select(type, select_options_as_html)
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 @@ def build_hidden(type, value)
: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
Please sign in to comment.
Something went wrong with that request. Please try again.