Class: ROM::AdapterPluginsContainer 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(type) ⇒ AdapterPluginsContainer

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


105
106
107
108
# File 'lib/rom/plugin_registry.rb', line 105

def initialize(type)
  @registries = ::Hash.new { |h, v| h[v] = PluginsContainer.new({}, type: type) }
  @type = 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)

99
100
101
# File 'lib/rom/plugin_registry.rb', line 99

def registries
  @registries
end

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


102
103
104
# File 'lib/rom/plugin_registry.rb', line 102

def type
  @type
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)

117
118
119
# File 'lib/rom/plugin_registry.rb', line 117

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:


134
135
136
137
138
139
140
# File 'lib/rom/plugin_registry.rb', line 134

def fetch(name, adapter_name = :default)
  adapter(adapter_name).fetch(name) do
    adapter(:default).fetch(name) do
      raise(UnknownPluginError, name)
    end
  end
end

#register(name, mod, options) ⇒ 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.


122
123
124
# File 'lib/rom/plugin_registry.rb', line 122

def register(name, mod, options)
  adapter(options.fetch(:adapter, :default)).register(name, mod, options)
end