Created
March 3, 2014 18:02
-
-
Save jamie/9330805 to your computer and use it in GitHub Desktop.
off the cuff spike at a per-account feature toggler
This file contains hidden or 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 FeatureCollection | |
| def initialize(account) | |
| @account = account | |
| end | |
| DEFAULTS = { | |
| 'currency' => 'cad', | |
| 'can_accept_credit_cards' => false, | |
| #... | |
| } | |
| def method_missing(name) | |
| feature = Feature.where(name => @account, :name => name).first | |
| if feature | |
| feature.value | |
| else | |
| DEFAULTS[name.to_s] | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment