Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active September 13, 2017 01:57
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 Sihui/b866ba79d8a62e44c80abf83586ae725 to your computer and use it in GitHub Desktop.
Save Sihui/b866ba79d8a62e44c80abf83586ae725 to your computer and use it in GitHub Desktop.
Design Pattern: Template Method and Chipotle Raw
class DietOrder
def vessel
raise 'What is your choice?'
end
def meat
raise 'What is your choice?'
end
def toppings
Tomato
end
def extras
nil
end
def order
meal = vessel
meal << meat
meal << toppings
meal << extras
meal
end
end
class DietOrderSihui < DietOrder
def vessel
Bowl
end
def meat
Steak
end
end
class DietOrderAmber < DietOrder
def vessel
Burrito
end
def meat
Chicken
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment