Created
February 13, 2015 23:07
-
-
Save rewinfrey/5a70d8b2204032ac0d7d to your computer and use it in GitHub Desktop.
Example Strategy Factory
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
# this would be called in the controller, | |
# whose return value is the Strategy class | |
class CandidateJobDocumentStrategyFactory | |
def self.strategy_for(document_type) | |
case document_type | |
when :resume then resume_strategy | |
when :cover_letter then cover_letter_strategy | |
when :application then application_strategy | |
end | |
end | |
def self.resume_strategy | |
ResumeStrategy | |
end | |
def self.cover_letter_strategy | |
CoverLetterStrategy | |
end | |
def self.application_strategy | |
ApplicationStrategy | |
end | |
class ResumeStrategy | |
def self.execute(candidate_job, resume) | |
# business logic of associating the resume to the candidate_job | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment