An elementary feature toggle implementation
Add this line to your application's Gemfile:
gem 'bit_toggle'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bit_toggle
To enable a feature for a single object:
user = User.find(username)
BitToggle.enable(:my_new_feature, user)
To enable a bit toggle globally:
BitToggle.enable_globally(:my_new_feature)
To verify if a feature is enabled:
BitToggle.enabled?(:my_new_feature, user)
To implement this in your codebase:
def perform
if BitToggle.enabled?(:my_new_feature, user)
do_the_new_feature
else
do_the_old_feature
end
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request