lib/flipper/adapters/mongo.rb in flipper-mongo-0.21.0.rc1 vs lib/flipper/adapters/mongo.rb in flipper-mongo-0.21.0.rc2

- old
+ new

@@ -11,10 +11,13 @@ FeaturesKey = :flipper_features # Public: The name of the adapter. attr_reader :name + # Public: The name of the collection storing the feature data. + attr_reader :collection + def initialize(collection) @collection = collection @name = :mongo end @@ -169,7 +172,20 @@ end end result end end + end +end + +Flipper.configure do |config| + config.adapter do + url = ENV["FLIPPER_MONGO_URL"] || ENV["MONGO_URL"] + collection = ENV["FLIPPER_MONGO_COLLECTION"] || "flipper" + + unless url + raise ArgumentError, "The MONGO_URL environment variable must be set. For example: mongodb://127.0.0.1:27017/flipper" + end + + Flipper::Adapters::Mongo.new(Mongo::Client.new(url)[collection]) end end