Class: ROM::PluginRegistry Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializePluginRegistry

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

#typesObject (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

Parameters:

  • name (Symbol)

    The registration name for the plugin

  • mod (Module)

    The plugin to register

  • options (Hash) (defaults to: EMPTY_HASH)

    optional configuration data

Options Hash (options):

  • :type (Symbol)

    What type of plugin this is (command,

  • :adapter (Symbol) — default: :default

    which adapter this plugin



29
30
31
# File 'core/lib/rom/plugin_registry.rb', line 29

def register(name, mod, options = EMPTY_HASH)
  type(options.fetch(:type)).register(name, mod, options)
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