Created
April 11, 2012 12:54
-
-
Save dhiemstra/2359132 to your computer and use it in GitHub Desktop.
Mobile crap
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
# Public: Returns an optimized hash object for mobile representation of weekly activities. | |
# | |
# The returned hash would look like this {"Monday" => [schedule_items], "Tuesday" => [], ...} | |
def current_week_for_mobile | |
start = proxy_association.owner.local_time.beginning_of_week | |
end = proxy_association.owner.local_time.end_of_week | |
(start..end).inject({}) do |memo,day| | |
memo[Date::DAYNAMES[day.wday]] = ScheduleItem.where(date: day.to_date) | |
memo | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment