Skip to content

Instantly share code, notes, and snippets.

@mbriggs
Created May 6, 2013 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbriggs/5526196 to your computer and use it in GitHub Desktop.
Save mbriggs/5526196 to your computer and use it in GitHub Desktop.
functional api
# I think having the "functional" api to the rest of the system is the important part, if those functions happen to use objects, thats fine to me.
# in this case we are treating the "object" as a way to partially apply all the private functions to share the same arg
# IMO the only "danger" with using objects in this type of place is that you are going to hesitate if you want to add functions
# which do not use "all_events". In this case I think its probably fine, since "ReconcilesEvents" implies working on the full collection
class ReconcilesEvents
def self.tasks_that_have_not_ended(all_events)
new(all_events).unended_tasks
end
attr_reader :all_events
def initialize(all_events)
@all_events = all_events
end
def unended_tasks
# ....
end
private
def start_events
all_events.start_events
end
def end_events
all_events.end_events
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment