Skip to content

Commit

Permalink
Refactor: Extract Method
Browse files Browse the repository at this point in the history
Extracted duplicated code into a utility method.
  • Loading branch information
edavis10 committed Jan 29, 2010
1 parent 894c173 commit 9de6913
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/helpers/bulk_time_entries_helper.rb
Expand Up @@ -23,16 +23,19 @@ def grouped_options_for_issues(issues)

html = '<option></option>'
unless open_issues.empty?
html << "<optgroup label='#{l(:label_open_issues)}'>"
html << options_from_collection_for_select(open_issues, :id, :to_s)
html << "</optgroup>"
html << labeled_option_group_from_collection_for_select(:label_open_issues, open_issues)
end

unless closed_issues.empty?
html << "<optgroup label='#{l(:label_closed_issues)}'>"
html << options_from_collection_for_select(closed_issues, :id, :to_s)
html << "</optgroup>"
html << labeled_option_group_from_collection_for_select(:label_closed_issues, closed_issues)
end
html
end

def labeled_option_group_from_collection_for_select(label, collection)
html = "<optgroup label='#{l(label)}'>"
html << options_from_collection_for_select(collection, :id, :to_s)
html << "</optgroup>"
html
end
end

0 comments on commit 9de6913

Please sign in to comment.