Class: ROM::InternalPluginRegistry Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Store a set of registries grouped by adapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin_type = Plugin) ⇒ InternalPluginRegistry

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 InternalPluginRegistry.



167
168
169
# File 'lib/rom/plugin_registry.rb', line 167

def initialize(plugin_type = Plugin)
  @registries = Hash.new { |h, v| h[v] = AdapterPluginRegistry.new({}, plugin_type: plugin_type) }
end

Instance Attribute Details

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

Return the existing registries

Returns:

  • (Hash)


164
165
166
# File 'lib/rom/plugin_registry.rb', line 164

def registries
  @registries
end

Instance Method Details

#adapter(name) ⇒ AdapterRegistry

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.

Return the plugin registry for a specific adapter

Parameters:

  • name (Symbol)

    The name of the adapter

Returns:

  • (AdapterRegistry)


178
179
180
# File 'lib/rom/plugin_registry.rb', line 178

def adapter(name)
  registries[name]
end

#fetch(name, adapter_name = :default) ⇒ Object Also known as: []

Return the plugin for a given adapter

Parameters:

  • name (Symbol)

    The name of the plugin

  • adapter_name (Symbol) (defaults to: :default)

    (:default) The name of the adapter used

Raises:



190
191
192
193
# File 'lib/rom/plugin_registry.rb', line 190

def fetch(name, adapter_name = :default)
  adapter(adapter_name)[name] || adapter(:default)[name] ||
    raise(UnknownPluginError, name)
end