require 'bundler/setup' require 'sequel' Sequel::Model.db = Sequel.sqlite(':memory:') Sequel.extension :migration, :core_extensions require 'generators/flipper/templates/sequel_migration' CreateFlipperTablesSequel.new(Sequel::Model.db).up require 'flipper/adapters/sequel' # Register a few groups. Flipper.register(:admins) { |actor| actor.admin? } Flipper.register(:early_access) { |actor| actor.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 Flipper[:search].enable puts 'all rows in features table' pp Flipper::Adapters::Sequel::Feature.all #[#"stats", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"search", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>] puts puts 'all rows in gates table' pp Flipper::Adapters::Sequel::Gate.all # [#"stats", :key=>"boolean", :value=>"true", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"groups", :value=>"admins", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"groups", :value=>"early_access", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"actors", :value=>"25", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"actors", :value=>"90", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"actors", :value=>"180", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"percentage_of_time", :value=>"15", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"stats", :key=>"percentage_of_actors", :value=>"45", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>, # #"search", :key=>"boolean", :value=>"true", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>] puts puts 'flipper get of feature' pp Flipper.adapter.get(Flipper[:stats]) # {:boolean=>"true", # :groups=>#, # :actors=>#, # :percentage_of_actors=>"45", # :percentage_of_time=>"15"}