Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active July 14, 2017 15:19
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/e3ad377ee27d2f5190bf4234f98c72a2 to your computer and use it in GitHub Desktop.
Save Sihui/e3ad377ee27d2f5190bf4234f98c72a2 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
is_cheat_day? ? Soda : nil
end
def is_cheat_day?
false
end
def order
meal = vessel
meal << meat
meal << toppings
meal << extras
meal
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment