Class: ROM::PluginRegistry Private
- Inherits:
-
Object
- Object
- ROM::PluginRegistry
- 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.
Stores all registered plugins
Instance Attribute Summary collapse
- #types ⇒ Object readonly private
Instance Method Summary collapse
- #[](type) ⇒ Object private
-
#initialize ⇒ PluginRegistry
constructor
private
A new instance of PluginRegistry.
-
#register(name, mod, options = EMPTY_HASH) ⇒ Object
private
Register a plugin for future use.
-
#singularize(type) ⇒ Object
private
Old API compatibility.
- #type(type) ⇒ Object private
Constructor Details
#initialize ⇒ PluginRegistry
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 PluginRegistry.
16 17 18 |
# File 'core/lib/rom/plugin_registry.rb', line 16 def initialize @types = ::Concurrent::Map.new end |
Instance Attribute Details
#types ⇒ 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.
13 14 15 |
# File 'core/lib/rom/plugin_registry.rb', line 13 def types @types end |
Instance Method Details
#[](type) ⇒ 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.
45 46 47 |
# File 'core/lib/rom/plugin_registry.rb', line 45 def [](type) types.fetch(singularize(type)) end |
#register(name, mod, options = EMPTY_HASH) ⇒ 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.
Register a plugin for future use
relation or mapper) applies to. Leave blank for all adapters
29 30 31 |
# File 'core/lib/rom/plugin_registry.rb', line 29 def register(name, mod, = EMPTY_HASH) type(.fetch(:type)).register(name, mod, ) end |
#singularize(type) ⇒ 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.
Old API compatibility
52 53 54 55 56 57 58 59 60 |
# File 'core/lib/rom/plugin_registry.rb', line 52 def singularize(type) case type when :relations then :relation when :commands then :command when :mappers then :mapper when :schemas then :schema else type end end |
#type(type) ⇒ 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.
34 35 36 37 38 39 40 41 42 |
# File 'core/lib/rom/plugin_registry.rb', line 34 def type(type) types.fetch_or_store(type) do if Plugins[type][:adapter] AdapterPluginsContainer.new(type) else PluginsContainer.new({}, type: type) end end end |