Skip to content

Instantly share code, notes, and snippets.

@rachidcalazans
Last active September 29, 2018 03:55
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 rachidcalazans/6d2cf4f66362ed6d70ca86e3934c8d1d to your computer and use it in GitHub Desktop.
Save rachidcalazans/6d2cf4f66362ed6d70ca86e3934c8d1d to your computer and use it in GitHub Desktop.
Design Patterns in Ruby - Template Method
class CaffeineBeverage
def prepare_recipe
boil_water
brew_condiments # new method
add_aditional_condiments # new method
pour_in_cup
end
private
def brew_condiments; end # Abstract method
def add_aditional_condiments; end # Abstract method
def boil_water
puts 'boil water'
end
def pour_in_cup
puts 'pour in cup'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment