Documentation
¶
Overview ¶
Package chain_of_responsibility implements the Chain Of Responsibility design pattern. Meals are prepared by executing a sequence of cooking steps, each represented as a process in a chain. Every process performs a specific action and delegates to the next step by calling its Handle() method. After the final step, a printable receipt is generated to represent the completed meal.
Index ¶
Constants ¶
const ( Wiener byte = iota Frankfurter Bratwurst Soy )
Sausage type enums
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddBun ¶
type AddBun struct {
CookingStep
// contains filtered or unexported fields
}
AddBun is the cooking process that adds the bun in the specific place of the meal.
type AddPatty ¶
type AddPatty struct {
CookingStep
}
AddPatty is the cooking process that adds the patty to the meal.
type AddSauce ¶
type AddSauce struct {
CookingStep
}
AddSauce is the cooking process that adds one of the random sauce to the meal.
type AddSausage ¶
type AddSausage struct {
CookingStep
// contains filtered or unexported fields
}
AddSausage is the cooking process that adds the sausage of the specific type to the meal.
type AddVeggies ¶
type AddVeggies struct {
CookingStep
}
AddVeggies is the cooking process that adds 2 random veggies to the meal.
type Chainable ¶
Chainable defines the interface for a processing step in the chain of responsibility. Each step processes part of a meal and delegates to the next step, if any.
type Combinable ¶
Combinable declares the interface of a completed meal that can accumulate layers and could be rendered as a string.
type CookingStep ¶
type CookingStep struct {
Meal Combinable
// contains filtered or unexported fields
}
CookingStep is the abstract struct that implements the Addable interface and encapsulates the reference to the meal that is cooking and the next step in chain.
func (*CookingStep) AddNext ¶
func (c *CookingStep) AddNext(nextStep Chainable) Chainable
AddNext allows to add the next chainable abstraction to the chain.
type Layerable ¶
type Layerable interface {
AddLayer(string)
}
Layerable defines how ingredients or modifications are added to a meal.