Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active July 27, 2017 15:43
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/d9f6fc4c28c56b72257fd181513db12e to your computer and use it in GitHub Desktop.
Save Sihui/d9f6fc4c28c56b72257fd181513db12e to your computer and use it in GitHub Desktop.
Design Pattern: Command and Hotel Service
class RoomService
attr_reader :data, :kitchen
def initialize(data)
@data = data
@kitchen = Kitchen.new
end
def execute
kitchen.cook_for(data)
end
end
class LaundryService
attr_reader :data, :cleaning_dpt
def initialize(data)
@data = data
@cleaning_dpt = CleaningDepartment.new
end
def execute
cleaning_dpt.do_laundry_for(data)
end
end
class TripPlanningService
attr_reader :data, :tripAdvisor
def initialize(data)
@data = data
@tripAdvisor = TripAdvisor.new
end
def execute
tripAdvisor.plan_for(data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment