Class: Hanami::Providers::DB::Config

Inherits:
Dry::Configurable::Config
  • Object
show all
Includes:
Dry::Core::Constants
Defined in:
lib/hanami/providers/db/config.rb

Overview

Since:

  • 2.2.0

Instance Method Summary collapse

Instance Method Details

#adapter(name) {|adapter| ... } ⇒ Object

Yields:

Since:

  • 2.2.0



23
24
25
26
27
# File 'lib/hanami/providers/db/config.rb', line 23

def adapter(name)
  adapter = adapters.adapter(name)
  yield adapter if block_given?
  adapter
end

#each_pluginObject

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.

Since:

  • 2.2.0



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hanami/providers/db/config.rb', line 30

def each_plugin
  return to_enum(__method__) unless block_given?

  gateways.values.group_by(&:adapter_name).each do |adapter_name, adapter_gateways|
    per_adapter_plugins = adapter_gateways.map { _1.adapter.plugins }.flatten(1).uniq

    per_adapter_plugins.each do |plugin_spec, config_block|
      yield adapter_name, plugin_spec, config_block
    end
  end
end

#gateway(key) {|gateway| ... } ⇒ Object

Yields:

Since:

  • 2.2.0



15
16
17
18
19
# File 'lib/hanami/providers/db/config.rb', line 15

def gateway(key)
  gateway = (gateways[key] ||= Gateway.new)
  yield gateway if block_given?
  gateway
end