Moneta Adapter
A Moneta adapter for Flipper.
Installation
Add it to your application's Gemfile with:
$ bundle add flipper-moneta
Or install it yourself with:
$ gem install flipper-moneta
Usage
require 'flipper/adapters/moneta'
moneta = Moneta.new(:Memory)
Flipper.configure do |config|
config.adapter { Flipper::Adapters::Moneta.new(moneta) }
end
Internals
Each feature is stored as a key namespaced by flipper_features
.
require 'flipper/adapters/moneta'
moneta = Moneta.new(:Memory)
Flipper.configure do |config|
config.adapter { Flipper::Adapters::Moneta.new(moneta) }
end
# Register a few groups.
Flipper.register(:admins) { |thing| thing.admin? }
Flipper.register(:early_access) { |thing| thing.early_access? }
# Create a user class that has flipper_id instance method.
User = Struct.new(:flipper_id)
Flipper[:stats].enable
Flipper[:stats].enable_group :admins
Flipper[:stats].enable_group :early_access
Flipper[:stats].enable_actor User.new('25')
Flipper[:stats].enable_actor User.new('90')
Flipper[:stats].enable_actor User.new('180')
Flipper[:stats].enable_percentage_of_time 15
Flipper[:stats].enable_percentage_of_actors 45
pp moneta["flipper_features/stats"]
{:boolean=>"true",
:groups=>#<Set: {"admins", "early_access"}>,
:actors=>#<Set: {"25", "90", "180"}>,
:percentage_of_actors=>"45",
:percentage_of_time=>"15"}
Ready to try it out?
Get audit history, rollbacks, advanced permissions, analytics, and all of your projects in one place.
Prefer our Cloudless option?
You can choose from several tiers to sponsor Flipper on GitHub and get some great benefits!