Skip to content

Instantly share code, notes, and snippets.

@ramontayag
Created September 13, 2010 16:58
Show Gist options
  • Save ramontayag/577628 to your computer and use it in GitHub Desktop.
Save ramontayag/577628 to your computer and use it in GitHub Desktop.
class GroupByDrop << Liquid::Drop
def initialize(objects)
@objects = objects
end
def published_at_beginning_of_year_then_month
objects = ActiveSupport::OrderedHash.new
objects_by_year = @objects.group_by { |o| o.published_at.beginning_of_year }
objects_by_year.each do |time, objects_of_year|
objects[time] = objects_of_year.group_by { |o_year| o_year.published_at.beginning_of_month}
end
objects
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment