Skip to content

Instantly share code, notes, and snippets.

@alvir
Created November 2, 2012 09:26
Show Gist options
  • Save alvir/3999725 to your computer and use it in GitHub Desktop.
Save alvir/3999725 to your computer and use it in GitHub Desktop.
Typical smell. Conditions in extended array
def listed_date_links(feed_search, since_last_visit = false)
['Any', FeedSearch::SINCE_LAST_VIEW_VALUE, *FeedSearch::LAST_DAYS_VALUES].each do |col|
if col == current_listed_date_column(feed_search, since_last_visit).to_s
concat content_tag(:div, title_listed_date(col), :class => 'active')
else
concat link_to(title_listed_date(col), '#', :column_name => col, :class => 'subheader_link listed_date_column')
end
end
end
def current_listed_date_column(feed_search, since_last_visit = false)
return FeedSearch::SINCE_LAST_VIEW_VALUE if since_last_visit
feed_search.listed_date || 'Any'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment