Class: ROM::Plugins::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/plugins/dsl.rb

Overview

Plugin registration DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



26
27
28
29
30
# File 'lib/rom/plugins/dsl.rb', line 26

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)


16
17
18
# File 'lib/rom/plugins/dsl.rb', line 16

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:

  • (PluginRegistry)


23
24
25
# File 'lib/rom/plugins/dsl.rb', line 23

def registry
  @registry
end

Instance Method Details

#adapter(type, &block) ⇒ Object

Register plugins for a specific adapter

Parameters:

  • type (Symbol)

    The adapter identifier



48
49
50
# File 'lib/rom/plugins/dsl.rb', line 48

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)

    Name of a plugin

  • mod (Module)

    Plugin module

  • options (Hash) (defaults to: EMPTY_HASH)


39
40
41
# File 'lib/rom/plugins/dsl.rb', line 39

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