Created
August 5, 2019 00:04
-
-
Save vl3/e66cb88a48117eb53388d83aaaf6bd72 to your computer and use it in GitHub Desktop.
Feature toggle
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
class FeatureToggle(object): | |
def __init__(self, old, new, toggle): | |
self.old = old | |
self.new = new | |
self.toggle = toggle | |
def __getattr__(self, name): | |
def wrapper(*args, **kwargs): | |
instance_to_use = self.new if self.toggle else self.old | |
return getattr(instance_to_use, name)(*args, **kwargs) | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment