Last active
November 18, 2019 12:11
-
-
Save AlexPinhasov/1b4c6a4721c38897a34cdd8511f5db04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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