Created
May 6, 2013 16:23
-
-
Save mbriggs/5526196 to your computer and use it in GitHub Desktop.
functional api
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
# 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