Class: ROM::Global::PluginDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/global/plugin_dsl.rb

Overview

plugin registration DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry, defaults = EMPTY_HASH) ⇒ 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 'lib/rom/global/plugin_dsl.rb', line 24

def initialize(registry, defaults = EMPTY_HASH, &)
  @registry = registry
  @defaults = defaults
  instance_exec(&)
end

Instance Attribute Details

#defaultsHash (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 'lib/rom/global/plugin_dsl.rb', line 14

def defaults
  @defaults
end

#registryPluginRegistry (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 'lib/rom/global/plugin_dsl.rb', line 21

def registry
  @registry
end

Instance Method Details

#adapter(type) ⇒ Object

Register plugins for a specific adapter



46
47
48
# File 'lib/rom/global/plugin_dsl.rb', line 46

def adapter(type, &)
  self.class.new(registry, adapter: type, &)
end

#register(name, mod, options = EMPTY_HASH) ⇒ Object

Register a plugin



37
38
39
# File 'lib/rom/global/plugin_dsl.rb', line 37

def register(name, mod, options = EMPTY_HASH)
  registry.register(name, mod, defaults.merge(options))
end