require_relative "./ar_setup" # Requires the flipper-active_record gem to be installed. require 'flipper/adapters/active_record' # 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::ActiveRecord::Feature.all # [#, # #] puts puts 'all rows in gates table' pp Flipper::Adapters::ActiveRecord::Gate.all # [#, # #, # #, # #, # #, # #, # #, # #, # #] puts puts 'flipper get of feature' pp Flipper.adapter.get(Flipper[:stats]) # flipper get of feature