Feature flag support. For turning your application's features off and on again.
Add this line to your application's Gemfile:
gem 'feature'
And then execute:
$ bundle
Or install it yourself as:
$ gem install feature
Feature
can be configured using your applications initialization block:
Feature.configure do |config|
config.features = YourFeatureHash || {}
config.feature_thresholds = YourFeatureThresholdHash || {}
config.whitelist = YourWhitelistArray || []
config.abbreviations = YourAbbreviationHash || {}
end
The main usage of Feature
is after setting features
in the config block, enabled?
can be used to check the boolean state of any feature. This is augmented in several ways:
Feature thresholds allows us to segment traffic for a feature, so we can have (e.g.) category filters in the search page for 10% of traffic. In order to use this, simply set the following in feature_thresholds: {search_category_filters: 0.1}
. The 0.1 represents the 10% of people who will get "true" for this feature.
Whitelist is fairly straighforward; This is an array of features that can be configured and overridden separately to normal features. This is done with the aim of supporting parameter overrides of particular features.
Abbreviations simply allow for a simpler way to reference long feature keys; for example you might set it to {longkey: ludicrously_over_needed_giant_key_example_yo}
to allow for easier use.
- Fork it ( https://github.com/[my-github-username]/feature/fork )
- 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 a new Pull Request