Class: ROM::Global::PluginDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/global/plugin_dsl.rb

Overview

plugin registration DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry, defaults = EMPTY_HASH, &block) ⇒ PluginDSL

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 PluginDSL.


24
25
26
27
28
# File 'lib/rom/global/plugin_dsl.rb', line 24

def initialize(registry, defaults = EMPTY_HASH, &block)
  @registry = registry
  @defaults = defaults
  instance_exec(&block)
end

Instance Attribute Details

#defaultsHash (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.

Default options passed to plugin registration

Returns:

  • (Hash)

14
15
16
# File 'lib/rom/global/plugin_dsl.rb', line 14

def defaults
  @defaults
end

#registryPluginRegistry (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.

Plugin registry

Returns:


21
22
23
# File 'lib/rom/global/plugin_dsl.rb', line 21

def registry
  @registry
end

Instance Method Details

#adapter(type, &block) ⇒ Object

Register plugins for a specific adapter

Parameters:

  • type (Symbol)

    The adapter identifier


46
47
48
# File 'lib/rom/global/plugin_dsl.rb', line 46

def adapter(type, &block)
  self.class.new(registry, adapter: type, &block)
end

#register(name, mod, options = EMPTY_HASH) ⇒ Object

Register a plugin

Parameters:

  • name (Symbol)

    of the plugin

  • mod (Module)

    to include

  • options (Hash) (defaults to: EMPTY_HASH)

37
38
39
# File 'lib/rom/global/plugin_dsl.rb', line 37

def register(name, mod, options = EMPTY_HASH)
  registry.register(name, mod, defaults.merge(options))
end