Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Created August 12, 2015 15:04
Show Gist options
  • Save lukemorton/0839fc9bcb5c90ed3b81 to your computer and use it in GitHub Desktop.
Save lukemorton/0839fc9bcb5c90ed3b81 to your computer and use it in GitHub Desktop.
# Usage:
#
# if FeatureToggle[:my_feature].enabled?
# something_with_new_feature
# end
#
# if FeatureToggle[:my_feature].disabled?
# something_without_new_feature
# end
#
# resources :turtles if FeatureToggle[:turtles].enabled?
#
class FeatureToggle < ActiveRecord::Base
def self.[](name)
find_or_initialize_by(name: name)
end
def enabled?
toggled?
end
def disabled?
toggled? == false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment