Skip to content

Commit

Permalink
Removing some unuseful begin/end and refactor prompt_option_tag a bit
Browse files Browse the repository at this point in the history
[#5469 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
carlosantoniodasilva authored and spastorino committed Aug 27, 2010
1 parent 983a5e2 commit 39f2f18
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions actionpack/lib/action_view/helpers/date_helper.rb
Expand Up @@ -751,10 +751,8 @@ def month_names
# => [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
# "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
def translated_month_names
begin
key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
I18n.translate(key, :locale => @options[:locale])
end
key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
I18n.translate(key, :locale => @options[:locale])
end

# Lookup month name for number
Expand All @@ -781,9 +779,7 @@ def date_order
memoize :date_order

def translated_date_order
begin
I18n.translate(:'date.order', :locale => @options[:locale]) || []
end
I18n.translate(:'date.order', :locale => @options[:locale]) || []
end

# Build full select tag from date type and options
Expand Down Expand Up @@ -837,15 +833,14 @@ def build_select(type, select_options_as_html)
# prompt_option_tag(:month, :prompt => 'Select month')
# => "<option value="">Select month</option>"
def prompt_option_tag(type, options)
default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}

case options
when Hash
prompt = default_options.merge(options)[type.to_sym]
when String
prompt = options
else
prompt = I18n.translate(('datetime.prompts.' + type.to_s).to_sym, :locale => @options[:locale])
prompt = case options
when Hash
default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
default_options.merge!(options)[type.to_sym]
when String
options
else
I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale])
end

prompt ? content_tag(:option, prompt, :value => '') : ''
Expand Down

0 comments on commit 39f2f18

Please sign in to comment.