Class: Hanami::Providers::DB::Adapters

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hanami/providers/db/adapters.rb

Overview

Since:

  • 2.2.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAdapters

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

Since:

  • 2.2.0



32
33
34
# File 'lib/hanami/providers/db/adapters.rb', line 32

def initialize
  @adapters = {}
end

Instance Attribute Details

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

Since:

  • 2.2.0



28
29
30
# File 'lib/hanami/providers/db/adapters.rb', line 28

def adapters
  @adapters
end

Class Method Details

.new_adapter(name) ⇒ 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.

Since:

  • 2.2.0



22
23
24
# File 'lib/hanami/providers/db/adapters.rb', line 22

def self.new_adapter(name)
  ADAPTER_CLASSES[name].new
end

Instance Method Details

#adapter(key) ⇒ 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.

Since:

  • 2.2.0



48
49
50
# File 'lib/hanami/providers/db/adapters.rb', line 48

def adapter(key)
  adapters[key] ||= new(key)
end

#find(key) ⇒ 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.

Since:

  • 2.2.0



54
55
56
# File 'lib/hanami/providers/db/adapters.rb', line 54

def find(key)
  adapters.fetch(key) { new(key) }
end

#initialize_copy(source) ⇒ 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.

Since:

  • 2.2.0



38
39
40
41
42
43
44
# File 'lib/hanami/providers/db/adapters.rb', line 38

def initialize_copy(source)
  @adapters = source.adapters.dup

  source.adapters.each do |key, val|
    @adapters[key] = val.dup
  end
end

#new(key) ⇒ 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.

Since:

  • 2.2.0



60
61
62
# File 'lib/hanami/providers/db/adapters.rb', line 60

def new(key)
  self.class.new_adapter(key)
end