Skip to content

Instantly share code, notes, and snippets.

@AlexPinhasov
Last active November 18, 2019 12:11
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 AlexPinhasov/1b4c6a4721c38897a34cdd8511f5db04 to your computer and use it in GitHub Desktop.
Save AlexPinhasov/1b4c6a4721c38897a34cdd8511f5db04 to your computer and use it in GitHub Desktop.
// 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