Class: ROM::PluginRegistryBase Private

Inherits:
Registry
  • Object
show all
Defined in:
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.

Abstract registry defining common behaviour

Instance Attribute Summary collapse

Attributes inherited from Registry

#cache, #elements

Instance Method Summary collapse

Methods inherited from Registry

#each, element_not_found_error, #fetch, #key?, #map, #merge, new, #respond_to_missing?, #to_hash

Methods included from Initializer

extended

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROM::Registry

Instance Attribute Details

#plugin_typeClass (readonly)

Returns Typically ROM::PluginBase or its descendant.

Returns:

  • (Class)

    Typically ROM::PluginBase or its descendant



92
# File 'lib/rom/plugin_registry.rb', line 92

option :plugin_type

Instance Method Details

#[](name) ⇒ Plugin

Retrieve a registered plugin

Parameters:

  • name (Symbol)

    The plugin to retrieve

Returns:



101
102
103
# File 'lib/rom/plugin_registry.rb', line 101

def [](name)
  elements[name]
end

#plugin_name(plugin) ⇒ Symbol

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 plugin name by instance

Returns:

  • (Symbol)

    Plugin name



121
122
123
124
# File 'lib/rom/plugin_registry.rb', line 121

def plugin_name(plugin)
 tuple = elements.find { |(_, p)| p.equal?(plugin) }
 tuple[0] if tuple
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.

Assign a plugin to this environment registry

Parameters:

  • name (Symbol)

    The registered plugin name

  • mod (Module)

    The plugin to register

  • options (Hash)

    optional configuration data



112
113
114
# File 'lib/rom/plugin_registry.rb', line 112

def register(name, mod, options)
  elements[name] = plugin_type.new(mod, options)
end