Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active July 16, 2017 16:10
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/bd082dae745ba0be0e9b1bc482957edb to your computer and use it in GitHub Desktop.
Save Sihui/bd082dae745ba0be0e9b1bc482957edb to your computer and use it in GitHub Desktop.
Design Pattern: Decorator and Waffle
class StrawberryWaffle
attr_reader :waffle
attr_accessor :topping
def initialize(waffle)
@waffle = waffle
@topping = 'strawberries'
end
def serve
waffle.serve
puts " topped with #{topping}"
end
def eat
waffle.eat
puts " and then eat some #{topping}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment