Skip to content

Instantly share code, notes, and snippets.

@udit99
Created April 5, 2013 22:40
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 udit99/5323252 to your computer and use it in GitHub Desktop.
Save udit99/5323252 to your computer and use it in GitHub Desktop.
module Cookable
def make_into dish
dish.make_into self
end
def to_s
self.class.to_s
end
end
class Chicken
include Cookable
end
class Beef
include Cookable
end
class Sandwich
def make_into meat
puts "#{meat} Sandwich"
end
end
class Stew
def make_into meat
puts "#{meat} Stew"
end
end
class Casserole
def make_into meat
puts "#{meat} Casserole"
end
end
class Restaurant
def initialize meat
@meat = meat
end
def make_sandwich
@meat.make_into Sandwich.new
end
def make_stew
@meat.make_into Stew.new
end
def make_casserole
@meat.make_into Casserole.new
end
end
smokies = Restaurant.new(Chicken.new)
smokies.make_sandwich
smokies.make_stew
smokies.make_casserole
smokies = Restaurant.new(Beef.new)
smokies.make_sandwich
smokies.make_stew
smokies.make_casserole
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment