Skip to content

Instantly share code, notes, and snippets.

View dhiemstra's full-sized avatar

Danny Hiemstra dhiemstra

View GitHub Profile
# 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