Class: ROM::Global::PluginDSL
- Inherits:
-
Object
- Object
- ROM::Global::PluginDSL
- Defined in:
- core/lib/rom/global/plugin_dsl.rb
Overview
plugin registration DSL
Instance Attribute Summary collapse
-
#defaults ⇒ Hash
readonly
private
Default options passed to plugin registration.
-
#registry ⇒ PluginRegistry
readonly
private
Plugin registry.
Instance Method Summary collapse
-
#adapter(type, &block) ⇒ Object
Register plugins for a specific adapter.
-
#initialize(registry, defaults = EMPTY_HASH, &block) ⇒ PluginDSL
constructor
private
A new instance of PluginDSL.
-
#register(name, mod, options = EMPTY_HASH) ⇒ Object
Register a plugin.
Constructor Details
#initialize(registry, defaults = EMPTY_HASH, &block) ⇒ PluginDSL
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.
Returns a new instance of PluginDSL.
24 25 26 27 28 |
# File 'core/lib/rom/global/plugin_dsl.rb', line 24 def initialize(registry, defaults = EMPTY_HASH, &block) @registry = registry @defaults = defaults instance_exec(&block) end |
Instance Attribute Details
#defaults ⇒ Hash (readonly)
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.
Default options passed to plugin registration
14 15 16 |
# File 'core/lib/rom/global/plugin_dsl.rb', line 14 def defaults @defaults end |
#registry ⇒ PluginRegistry (readonly)
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.
Plugin registry
21 22 23 |
# File 'core/lib/rom/global/plugin_dsl.rb', line 21 def registry @registry end |
Instance Method Details
#adapter(type, &block) ⇒ Object
Register plugins for a specific adapter
46 47 48 |
# File 'core/lib/rom/global/plugin_dsl.rb', line 46 def adapter(type, &block) self.class.new(registry, adapter: type, &block) end |
#register(name, mod, options = EMPTY_HASH) ⇒ Object
Register a plugin
37 38 39 |
# File 'core/lib/rom/global/plugin_dsl.rb', line 37 def register(name, mod, = EMPTY_HASH) registry.register(name, mod, defaults.merge()) end |