class ROM::PluginRegistry

Stores all registered plugins

@api private

Attributes

types[R]

@api private

Public Class Methods

new() click to toggle source

@api private

# File lib/rom/plugin_registry.rb, line 16
def initialize
  @types = ::Concurrent::Map.new
end

Public Instance Methods

[](type) click to toggle source

@api private

# File lib/rom/plugin_registry.rb, line 45
def [](type)
  types.fetch(singularize(type))
end
register(name, mod, options = EMPTY_HASH) click to toggle source

Register a plugin for future use

@param [Symbol] name The registration name for the plugin @param [Module] mod The plugin to register @param [Hash] options optional configuration data @option options [Symbol] :type What type of plugin this is (command, relation or mapper) @option options [Symbol] :adapter (:default) which adapter this plugin applies to. Leave blank for all adapters

# File 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) click to toggle source

Old API compatibility

@api private

# File 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) click to toggle source

@api private

# File 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