Skip to content

Instantly share code, notes, and snippets.

@heftig
Created May 20, 2012 21:45
Show Gist options
  • Save heftig/2759658 to your computer and use it in GitHub Desktop.
Save heftig/2759658 to your computer and use it in GitHub Desktop.
def events_all_accounts(time)
self.accounts.flat_map do |account|
account.events.send(time, account.now).where(:client_id => self.id)
end.uniq.sort_by { |a| a.start_time }
end
private :events_all_accounts
# all upcoming events for a client
def future_events_all_accounts
events_all_accounts(:in_future)
end
# all past events for a client
def past_events_all_accounts
events_all_accounts(:in_past)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment