Module: Dry::Plugins::Host::DSL
- Defined in:
- lib/dry/plugins/host/dsl.rb
Overview
Mixin used as the DSL of the host class or module
Instance Method Summary collapse
- #inherited(child) ⇒ Object
- #plugins(&block) ⇒ Module, DSL
- #plugins_registry ⇒ Registry
-
#use(*names, &configuration) ⇒ <Symbol>
(Auto)load the plugin called
name
and apply it tohost
. - #used_plugins ⇒ <Symbol>
Instance Method Details
#inherited(child) ⇒ Object
81 82 83 84 |
# File 'lib/dry/plugins/host/dsl.rb', line 81 def inherited(child) super(child) child.instance_variable_set :@used_plugins, used_plugins.dup end |
#plugins(&block) ⇒ Module, DSL
75 76 77 78 79 |
# File 'lib/dry/plugins/host/dsl.rb', line 75 def plugins(&block) plugins = const_get(Plugins.config.plugins_module_name) return plugins.module_eval(&block) if block_given? plugins end |
#use(*names, &configuration) ⇒ <Symbol>
(Auto)load the plugin called name
and apply it to host
In case plugin name
is not registered yet,
registry will try to resolve that plugin by name
42 43 44 45 46 47 |
# File 'lib/dry/plugins/host/dsl.rb', line 42 def use(*names, &configuration) names.map do |name| plugin = plugins.plugins_registry.resolve(name) plugin.call(self, &configuration) end end |
#used_plugins ⇒ <Symbol>
70 71 72 |
# File 'lib/dry/plugins/host/dsl.rb', line 70 def used_plugins @used_plugins ||= Set.new end |