Module: Dry::System::Plugins
- Included in:
- Container
- Defined in:
- lib/dry/system/plugins.rb,
lib/dry/system/plugins/env.rb,
lib/dry/system/plugins/plugin.rb,
lib/dry/system/plugins/logging.rb,
lib/dry/system/plugins/bootsnap.rb,
lib/dry/system/plugins/zeitwerk.rb,
lib/dry/system/plugins/monitoring.rb,
lib/dry/system/plugins/notifications.rb,
lib/dry/system/plugins/dependency_graph.rb,
lib/dry/system/plugins/monitoring/proxy.rb,
lib/dry/system/plugins/zeitwerk/compat_inflector.rb,
lib/dry/system/plugins/dependency_graph/strategies.rb
Defined Under Namespace
Modules: Bootsnap, DependencyGraph, Logging, Monitoring, Notifications Classes: Env, Plugin, Zeitwerk
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
Enables a plugin if not already enabled.
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.
24 25 26 |
# File 'lib/dry/system/plugins.rb', line 24 def self.loaded_dependencies @loaded_dependencies ||= [] end |
.register(name, plugin, &block) ⇒ Plugins
Register a plugin
14 15 16 |
# File 'lib/dry/system/plugins.rb', line 14 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.
19 20 21 |
# File 'lib/dry/system/plugins.rb', line 19 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.
57 58 59 |
# File 'lib/dry/system/plugins.rb', line 57 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.
51 52 53 54 |
# File 'lib/dry/system/plugins.rb', line 51 def inherited(klass) klass.instance_variable_set(:@enabled_plugins, enabled_plugins.dup) super end |
#use(name, **options) ⇒ self
Enables a plugin if not already enabled. Raises error if plugin cannot be found in the plugin registry.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dry/system/plugins.rb', line 37 def use(name, **) return self if enabled_plugins.include?(name) raise PluginNotFoundError, name unless (plugin = Dry::System::Plugins.registry[name]) plugin.load_dependencies plugin.apply_to(self, **) enabled_plugins << name self end |