Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// MARK: - Toggle Logic For CarFleet
protocol CarFleetFeatureToggleLogic {
var fuelToUse: Fuel { get }
func transport(car: Car, to position: Position)
}
extension CarFleetFeatureToggleLogic where Self: CarFleet {
/**
Get the fuel to be used on cars.
- Toggle Options:
- Toggle on: return fuel type for rockets.
- Toggle off: return fuel type for cars.
*/
var fuelToUse: Fuel {
switch Toggles.Vehicle.carsCanFly.enabled {
case true : Fuel.rocket
case false : Fuel.car
}
}
/**
Transport cars to their destination.
- Toggle Options:
- Toggle on: Fly cars to destination.
- Toggle off: Drive cars to destination.
*/
func transport(car: Car, to position: Position) {
switch Toggles.Vehicle.carsCanFly.enabled {
case true : fly(to: location)
case false : drive(to: location)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment