Module: ROM::Global

Included in:
ROM
Defined in:
core/lib/rom/global.rb,
core/lib/rom/global/plugin_dsl.rb

Overview

Globally accessible public interface exposed via ROM module

Defined Under Namespace

Classes: PluginDSL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adaptersHash<Symbol=>Module> (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.

An internal adapter identifier => adapter module map used by setup

Returns:

  • (Hash<Symbol=>Module>)


26
27
28
# File 'core/lib/rom/global.rb', line 26

def adapters
  @adapters
end

#plugin_registryHash (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.

An internal identifier => plugin map used by the setup

Returns:

  • (Hash)


33
34
35
# File 'core/lib/rom/global.rb', line 33

def plugin_registry
  @plugin_registry
end

Class Method Details

.extended(rom) ⇒ Object

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.

Set base global registries in ROM constant



14
15
16
17
18
19
# File 'core/lib/rom/global.rb', line 14

def self.extended(rom)
  super

  rom.instance_variable_set('@adapters', {})
  rom.instance_variable_set('@plugin_registry', PluginRegistry.new)
end

Instance Method Details

#plugins(*args, &block) ⇒ Object

Global plugin setup DSL

Examples:

ROM.plugins do
  register :publisher, Plugin::Publisher, type: :command
end


43
44
45
# File 'core/lib/rom/global.rb', line 43

def plugins(*args, &block)
  PluginDSL.new(plugin_registry, *args, &block)
end

#register_adapter(identifier, adapter) ⇒ self

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.

Register adapter namespace under a specified identifier

Parameters:

  • identifier (Symbol)
  • adapter (Class, Module)

Returns:

  • (self)


55
56
57
58
# File 'core/lib/rom/global.rb', line 55

def register_adapter(identifier, adapter)
  adapters[identifier] = adapter
  self
end