class ROM::AdapterPluginsContainer
Store a set of registries grouped by adapter
@api private
Attributes
registries[R]
Return the existing registries
@return [Hash]
@api private
type[R]
@api private
Public Class Methods
new(type)
click to toggle source
@api private
# 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
Public Instance Methods
adapter(name)
click to toggle source
Return the plugin registry for a specific adapter
@param [Symbol] name The name of the adapter
@return [AdapterRegistry]
@api private
# File lib/rom/plugin_registry.rb, line 117 def adapter(name) registries[name] end
fetch(name, adapter_name = :default)
click to toggle source
Return the plugin for a given adapter
@param [Symbol] name The name of the plugin @param [Symbol] adapter_name (:default) The name of the adapter used
@raise [UnknownPluginError] if no plugin is found with the given name
@api public
# 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
Also aliased as: []
register(name, mod, options)
click to toggle source
@api private
# File lib/rom/plugin_registry.rb, line 122 def register(name, mod, options) adapter(options.fetch(:adapter, :default)).register(name, mod, options) end