Module: Dry::System::Plugins
- Included in:
- Container
- Defined in:
- lib/dry/system/plugins.rb,
lib/dry/system/plugins/env.rb,
lib/dry/system/plugins/logging.rb,
lib/dry/system/plugins/bootsnap.rb,
lib/dry/system/plugins/monitoring.rb,
lib/dry/system/plugins/notifications.rb,
lib/dry/system/plugins/monitoring/proxy.rb
Defined Under Namespace
Modules: Bootsnap, Logging, Monitoring, Notifications Classes: Env, Plugin
Class Method Summary collapse
- .loaded_dependencies ⇒ Object private
-
.register(name, plugin, &block) ⇒ Plugins
Register a plugin.
- .registry ⇒ Object private
Instance Method Summary collapse
- #enabled_plugins ⇒ Object private
- #inherited(klass) ⇒ Object private
-
#use(name, options = {}) ⇒ self
Enable a plugin.
Class Method Details
.loaded_dependencies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/dry/system/plugins.rb', line 69 def self.loaded_dependencies @__loaded_dependencies__ ||= [] end |
.register(name, plugin, &block) ⇒ Plugins
Register a plugin
59 60 61 |
# File 'lib/dry/system/plugins.rb', line 59 def self.register(name, plugin, &block) registry[name] = Plugin.new(name, plugin, &block) end |
.registry ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/dry/system/plugins.rb', line 64 def self.registry @__registry__ ||= {} end |
Instance Method Details
#enabled_plugins ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/dry/system/plugins.rb', line 101 def enabled_plugins @__enabled_plugins__ ||= [] end |
#inherited(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 98 |
# File 'lib/dry/system/plugins.rb', line 95 def inherited(klass) klass.instance_variable_set(:@__enabled_plugins__, enabled_plugins.dup) super end |
#use(name, options = {}) ⇒ self
Enable a plugin
Plugin identifier
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/dry/system/plugins.rb', line 83 def use(name, = {}) unless enabled_plugins.include?(name) plugin = Plugins.registry[name] plugin.load_dependencies plugin.apply_to(self, ) enabled_plugins << name end self end |