Skip to content

Instantly share code, notes, and snippets.

@jamie
Created March 3, 2014 18:02
Show Gist options
  • Select an option

  • Save jamie/9330805 to your computer and use it in GitHub Desktop.

Select an option

Save jamie/9330805 to your computer and use it in GitHub Desktop.
off the cuff spike at a per-account feature toggler
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