lib/super_settings/engine.rb in super_settings-0.0.1.rc3 vs lib/super_settings/engine.rb in super_settings-1.0.0

- old
+ new

@@ -5,10 +5,30 @@ # settings overriding behavior in the Configuration as well as eager loading the settings # into memory. class Engine < Rails::Engine isolate_namespace ::SuperSettings + initializer("SuperSettings") do + Rails.configuration.middleware.unshift(SuperSettings::Context::RackMiddleware) + + if defined?(ActiveJob::Base.around_perform) + ActiveJob::Base.around_perform do |job, block| + SuperSettings.context(&block) + end + end + + if defined?(Sidekiq.server?) && Sidekiq.server? + require_relative "context/sidekiq_middleware" + + Sidekiq.configure_server do |sidekiq_config| + sidekiq_config.server_middleware do |chain| + chain.prepend(SuperSettings::Context::SidekiqMiddleware) + end + end + end + end + config.after_initialize do # Call the deferred initialization block. configuration = Configuration.instance configuration.call @@ -43,9 +63,13 @@ end model_load_block = proc do Setting.cache = (configuration.model.cache || Rails.cache) Setting.storage = configuration.model.storage_class + + configuration.model.after_save_blocks.each do |block| + Setting.after_save(&block) + end if !SuperSettings.loaded? begin SuperSettings.load_settings rescue => e