Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'zlib'
module FeatureFlags
BETA_ACCOUNTS = %w(subdomain1 subdomain2)
FLAGS = {
:new_import_flow => {
:percentage => 10,
:account_subdomains => []
},
:last_emailed_with => {
:percentage => 25,
:account_subdomains => [
'coolcustomer',
'anothercoolcustomer'
]
}
}
def self.enabled_for_account?(account, feature)
if config = FLAGS[feature]
return true if BETA_ACCOUNTS.include?(account.subdomain)
return true if config[:account_subdomains] && config[:account_subdomains].include?(account.subdomain)
return true if Zlib.crc32("#{feature}:#{account.id}") % 100 < config[:percentage]
end
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.