Skip to content

Instantly share code, notes, and snippets.

@effkay
Created May 10, 2011 17:32
Show Gist options
  • Save effkay/964965 to your computer and use it in GitHub Desktop.
Save effkay/964965 to your computer and use it in GitHub Desktop.
Feature Switch
module Feature
@features = {
:xmas_design => Proc.new{ Date.strptime("2010-11-27", '%Y-%m-%d').past? || ['development', 'test'].include?(Rails.env) },
:some_fancy_feature => Proc.new{ ['development', 'test', 'staging'].include?(Rails.env) },
}
def self.is_enabled?(feature)
if @features.has_key? feature
@features[feature].call
end
end
end
if Feature.is_enabled? :some_fancy_feature
# do funky new stuff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment