diff --git a/config/application.rb b/config/application.rb index c10fb0bae18..9aca2d5c935 100644 --- a/config/application.rb +++ b/config/application.rb @@ -115,10 +115,7 @@ class Application < Rails::Application # Because this is easy to mess up, keep your initializers in order. # register plugins even before loading settings, as plugins can bring their own settings initializer :register_vmdb_plugins, :before => :load_vmdb_settings do - Rails.application.railties.each do |railtie| - next unless railtie.class.name.start_with?("ManageIQ::Providers::") || railtie.try(:vmdb_plugin?) - Vmdb::Plugins.instance.register_vmdb_plugin(railtie) - end + Vmdb::Plugins.instance.register_vmdb_plugins end initializer :load_vmdb_settings, :before => :load_config_initializers do diff --git a/lib/vmdb/plugins.rb b/lib/vmdb/plugins.rb index f9a593929cc..2a4be2caab0 100644 --- a/lib/vmdb/plugins.rb +++ b/lib/vmdb/plugins.rb @@ -2,7 +2,6 @@ module Vmdb class Plugins include Singleton - attr_reader :vmdb_plugins attr_reader :registered_automate_domains def initialize @@ -11,6 +10,19 @@ def initialize @vmdb_plugins = [] end + def vmdb_plugins + @vmdb_plugins.empty? ? register_vmdb_plugins : @vmdb_plugins + end + + def register_vmdb_plugins + Rails.application.railties.each do |railtie| + next unless railtie.class.name.start_with?("ManageIQ::Providers::") || railtie.try(:vmdb_plugin?) + register_vmdb_plugin(railtie) + end + + @vmdb_plugins + end + def register_vmdb_plugin(engine) @vmdb_plugins << engine