lib/flipper/railtie.rb in flipper-0.23.0 vs lib/flipper/railtie.rb in flipper-0.23.1

- old
+ new

@@ -8,39 +8,40 @@ instrumenter: ActiveSupport::Notifications, log: true ) 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.memoizer" do |app| - config = app.config.flipper + initializer "flipper.log", after: :load_config_initializers do |app| + flipper = app.config.flipper - if config.memoize - app.middleware.use Flipper::Middleware::Memoizer, { - env_key: config.env_key, - preload: config.preload, - if: config.memoize.respond_to?(:call) ? config.memoize : nil - } - end - end - - initializer "flipper.log" do |app| - config = app.config.flipper - if config.log && config.instrumenter == ActiveSupport::Notifications + if flipper.log && flipper.instrumenter == ActiveSupport::Notifications require "flipper/instrumentation/log_subscriber" end end - initializer "flipper.identifier" do - ActiveSupport.on_load(:active_record) do - ActiveRecord::Base.include Flipper::Identifier + 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