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.



22
23
24
25
26
# File 'lib/rom/global/plugin_dsl.rb', line 22

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)


12
13
14
# File 'lib/rom/global/plugin_dsl.rb', line 12

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:



19
20
21
# File 'lib/rom/global/plugin_dsl.rb', line 19

def registry
  @registry
end

Instance Method Details

#adapter(type, &block) ⇒ Object

Register plugins for a specific adapter

Parameters:

  • type (Symbol)

    The adapter identifier



44
45
46
# File 'lib/rom/global/plugin_dsl.rb', line 44

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)


35
36
37
# File 'lib/rom/global/plugin_dsl.rb', line 35

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