Class: ROM::Plugins::DSL
- Inherits:
-
Object
- Object
- ROM::Plugins::DSL
- Defined in:
- lib/rom/plugins/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) ⇒ DSL
constructor
private
A new instance of DSL.
-
#register(name, mod, options = EMPTY_HASH) ⇒ Object
Register a plugin.
Constructor Details
#initialize(registry, defaults = EMPTY_HASH, &block) ⇒ DSL
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 DSL.
26 27 28 29 30 |
# File 'lib/rom/plugins/dsl.rb', line 26 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
16 17 18 |
# File 'lib/rom/plugins/dsl.rb', line 16 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
23 24 25 |
# File 'lib/rom/plugins/dsl.rb', line 23 def registry @registry end |
Instance Method Details
#adapter(type, &block) ⇒ Object
Register plugins for a specific adapter
48 49 50 |
# File 'lib/rom/plugins/dsl.rb', line 48 def adapter(type, &block) self.class.new(registry, adapter: type, &block) end |
#register(name, mod, options = EMPTY_HASH) ⇒ Object
Register a plugin
39 40 41 |
# File 'lib/rom/plugins/dsl.rb', line 39 def register(name, mod, = EMPTY_HASH) registry.register(name, mod: mod, **defaults, **) end |