Sha256: 3f38873b1122b56379e61727d9c02ba8eb7570d37a6aba67c4aa2759733f9bff
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
require 'pp' require 'pathname' require 'logger' root_path = Pathname(__FILE__).dirname.join('..').expand_path lib_path = root_path.join('lib') $:.unshift(lib_path) require 'flipper/adapters/mongo' collection = Mongo::MongoClient.new.db('testing')['flipper'] adapter = Flipper::Adapters::Mongo.new(collection) flipper = Flipper.new(adapter) # 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 flipper.group(:admins) flipper[:stats].enable flipper.group(:early_access) flipper[:stats].enable User.new('25') flipper[:stats].enable User.new('90') flipper[:stats].enable User.new('180') flipper[:stats].enable flipper.random(15) flipper[:stats].enable flipper.actors(45) flipper[:search].enable puts 'all docs in collection' pp collection.find.to_a # all docs in collection # [{"_id"=>"stats", # "actors"=>["25", "90", "180"], # "boolean"=>"true", # "groups"=>["admins", "early_access"], # "percentage_of_actors"=>"45", # "percentage_of_random"=>"15"}, # {"_id"=>"flipper_features", "features"=>["stats", "search"]}, # {"_id"=>"search", "boolean"=>"true"}] puts puts 'flipper get of feature' pp adapter.get(flipper[:stats]) # flipper get of feature # {:boolean=>"true", # :groups=>#<Set: {"admins", "early_access"}>, # :actors=>#<Set: {"25", "90", "180"}>, # :percentage_of_actors=>"45", # :percentage_of_random=>"15"}
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flipper-mongo-0.6.0 | examples/internals.rb |
flipper-mongo-0.5.0 | examples/internals.rb |