1.7 KiB
1.7 KiB
Flop
A simple ruby feature flipper.
Installation
Add this line to your application's Gemfile:
gem 'flop'
And then execute:
$ bundle
Or install it yourself as:
$ gem install flop
Usage
Repositories
First, you need to configure where to store everything by setting a repository.
Available repositories are :
Flop::Repository::Memory
Flop::Repository::Redis
To set the repository, create a new object and affect it to Flop.repo
.
Flop.repo = Flop::Repository::Memory.new
require 'redis'
Flop.repo = Flop::Repository::Redis.new(Redis.new)
Features
To access a feature, you can call the Flop[] method or create a new Flop::Feature
object.
Flop[:example_feature] # is the same as
Flop::Feature.new(:example_feature)
Available methods on Flop::Feature
are :
feature.active?
returns true if the feature is activefeature.inactive?
returns true if the feature is inactivefeature.set(boolean)
sets the state of the feature to the passed valuefeature.activate
activates the featurefeature.deactivate
deactivates the featurefeature.toggle
toggles the state of the featurefeature.with { }
executes the block if the feature is activefeature.without { }
executes the block if the feature is inactive
Examples
Flop.repo = Flop::Repository::Memory.new
Flop[:feature].active? # => false
Flop[:feature].toggle # => true
Flop[:feature].with do
# code
end
Contributing
- Fork it ( https://github.com/gdott9/flop/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