Class: ROM::AdapterPluginsContainer Private
- Inherits:
-
Object
- Object
- ROM::AdapterPluginsContainer
- Defined in:
- core/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
-
#registries ⇒ Hash
readonly
private
Return the existing registries.
- #type ⇒ Object readonly private
Instance Method Summary collapse
-
#adapter(name) ⇒ AdapterRegistry
private
Return the plugin registry for a specific adapter.
-
#fetch(name, adapter_name = :default) ⇒ Object
(also: #[])
Return the plugin for a given adapter.
-
#initialize(type) ⇒ AdapterPluginsContainer
constructor
private
A new instance of AdapterPluginsContainer.
- #register(name, mod, options) ⇒ Object private
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 'core/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
#registries ⇒ Hash (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
99 100 101 |
# File 'core/lib/rom/plugin_registry.rb', line 99 def registries @registries end |
#type ⇒ Object (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 'core/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
117 118 119 |
# File 'core/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
134 135 136 137 138 139 140 |
# File 'core/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 'core/lib/rom/plugin_registry.rb', line 122 def register(name, mod, ) adapter(.fetch(:adapter, :default)).register(name, mod, ) end |