Sha256: a0c3a9a2e2223adbebc5d91606cebc7653bc0c0fa279a8e2814fd0587a8aab09
Contents?: true
Size: 1.57 KB
Versions: 9
Compression:
Stored size: 1.57 KB
Contents
module Flipper class Railtie < Rails::Railtie 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? ) 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| Flipper.configure do |config| config.default do Flipper.new(config.adapter, instrumenter: app.config.flipper.instrumenter) 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 end end
Version data entries
9 entries across 9 versions & 1 rubygems