Module: ROM::Global

Included in:
ROM
Defined in:
lib/rom/global.rb,
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>)


24
25
26
# File 'lib/rom/global.rb', line 24

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)


31
32
33
# File 'lib/rom/global.rb', line 31

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



12
13
14
15
16
17
# File 'lib/rom/global.rb', line 12

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


41
42
43
# File 'lib/rom/global.rb', line 41

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)


53
54
55
56
# File 'lib/rom/global.rb', line 53

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