Class: Dry::Plugins::Registry::Builder
- Inherits:
-
Object
- Object
- Dry::Plugins::Registry::Builder
- Defined in:
- lib/dry/plugins/registry/builder.rb
Overview
Build a plug-in registry for given host
Instance Attribute Summary collapse
- #registry_method ⇒ Symbol readonly
Instance Method Summary collapse
- #call(host, plugins: module_builder.call(host), registry_class: class_builder.call(plugins)) ⇒ Registry
-
#initialize(registry_method: Plugins.config.registry_method, **kwargs) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(registry_method: Plugins.config.registry_method, **kwargs) ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 |
# File 'lib/dry/plugins/registry/builder.rb', line 13 def initialize(registry_method: Plugins.config.registry_method, **kwargs) @registry_method = registry_method super(**kwargs) end |
Instance Attribute Details
#registry_method ⇒ Symbol (readonly)
19 20 21 |
# File 'lib/dry/plugins/registry/builder.rb', line 19 def registry_method @registry_method end |
Instance Method Details
#call(host, plugins: module_builder.call(host), registry_class: class_builder.call(plugins)) ⇒ Registry
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dry/plugins/registry/builder.rb', line 24 def call(host, plugins: module_builder.call(host), registry_class: class_builder.call(plugins)) unless plugins.respond_to? registry_method registry_variable = :"@#{registry_method}" plugins.define_singleton_method registry_method do if instance_variable_defined? registry_variable instance_variable_get registry_variable else instance_variable_set registry_variable, registry_class.new(plugins) end end end unless plugins.singleton_class.included_modules.include? DSL plugins.extend DSL end plugins.public_send registry_method end |