Created
September 13, 2010 16:58
-
-
Save ramontayag/577628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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