Sha256: c6bca7404a51c18842d108d0d2c323f7f0e27bd264acee3bf53b1e6a71297e5c
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
module Flipper class Engine < Rails::Engine paths["config/routes.rb"] = ["lib/flipper/cloud/routes.rb"] config.before_configuration do config.flipper = ActiveSupport::OrderedOptions.new.update( env_key: ENV.fetch('FLIPPER_ENV_KEY', 'flipper'), memoize: ENV.fetch('FLIPPER_MEMOIZE', 'true').casecmp('true').zero?, preload: ENV.fetch('FLIPPER_PRELOAD', 'true').casecmp('true').zero?, instrumenter: ENV.fetch('FLIPPER_INSTRUMENTER', 'ActiveSupport::Notifications').constantize, log: ENV.fetch('FLIPPER_LOG', 'true').casecmp('true').zero?, cloud_path: "_flipper" ) end initializer "flipper.identifier" do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.include Flipper::Identifier end end initializer "flipper.default", before: :load_config_initializers do |app| require 'flipper/cloud' if cloud? Flipper.configure do |config| config.default do if cloud? Flipper::Cloud.new( local_adapter: config.adapter, instrumenter: app.config.flipper.instrumenter ) else Flipper.new(config.adapter, instrumenter: app.config.flipper.instrumenter) end end end end initializer "flipper.log", after: :load_config_initializers do |app| flipper = app.config.flipper if flipper.log && flipper.instrumenter == ActiveSupport::Notifications require "flipper/instrumentation/log_subscriber" end end initializer "flipper.memoizer", after: :load_config_initializers do |app| flipper = app.config.flipper if flipper.memoize app.middleware.use Flipper::Middleware::Memoizer, { env_key: flipper.env_key, preload: flipper.preload, if: flipper.memoize.respond_to?(:call) ? flipper.memoize : nil } end end def cloud? !!ENV["FLIPPER_CLOUD_TOKEN"] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flipper-1.0.0 | lib/flipper/engine.rb |
flipper-1.0.0.pre | lib/flipper/engine.rb |