Skip to content

Commit

Permalink
Merge pull request #15057 from hayesr/reloadable_plugins
Browse files Browse the repository at this point in the history
Allow Vmdb::Plugins to work through code reloads in development.
  • Loading branch information
bdunne authored May 10, 2017
2 parents 3ef9d79 + 81b44aa commit 8bef42a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 1 addition & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion lib/vmdb/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Vmdb
class Plugins
include Singleton

attr_reader :vmdb_plugins
attr_reader :registered_automate_domains

def initialize
Expand All @@ -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

Expand Down

0 comments on commit 8bef42a

Please sign in to comment.