handle config already loaded before patching

If another plugin already accesses OpenProject::Configuration before the
patch is applied, the cost_reporting_cache_filter_classes method is
never generated as the effect of the patch is then only to set a default
value.
pull/6827/head
Jens Ulferts 9 years ago
parent 3c8aa8eb9b
commit 8375ed259b
  1. 16
      lib/open_project/reporting/patches/open_project/configuration_patch.rb

@ -24,7 +24,23 @@ module OpenProject::Reporting::Patches
module OpenProject::ConfigurationPatch module OpenProject::ConfigurationPatch
def self.included(base) def self.included(base)
base.class_eval do base.class_eval do
extend ModuleMethods
@defaults['cost_reporting_cache_filter_classes'] = true @defaults['cost_reporting_cache_filter_classes'] = true
if config_loaded_before_patch?
@config['cost_reporting_cache_filter_classes'] = true
end
end
end
module ModuleMethods
def config_loaded_before_patch?
@config.present? && !@config.has_key?('cost_reporting_cache_filter_classes')
end
def cost_reporting_cache_filter_classes
@config['cost_reporting_cache_filter_classes']
end end
end end
end end

Loading…
Cancel
Save