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.



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

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



95
96
97
# File 'lib/rom/plugin_registry.rb', line 95

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.



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

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



113
# File 'lib/rom/plugin_registry.rb', line 113

def adapter(name) = registries[name]

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

Return the plugin for a given adapter

Raises:



128
129
130
131
132
133
134
# File 'lib/rom/plugin_registry.rb', line 128

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.



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

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