Class: Hanami::Providers::DB::Adapters
- Inherits:
-
Object
- Object
- Hanami::Providers::DB::Adapters
- Extended by:
- Forwardable
- Defined in:
- lib/hanami/providers/db/adapters.rb
Overview
Instance Attribute Summary collapse
- #adapters ⇒ Object readonly private
Class Method Summary collapse
- .new_adapter(name) ⇒ Object private
Instance Method Summary collapse
- #adapter(key) ⇒ Object private
- #find(key) ⇒ Object private
-
#initialize ⇒ Adapters
constructor
private
A new instance of Adapters.
- #initialize_copy(source) ⇒ Object private
- #new(key) ⇒ Object private
Constructor Details
#initialize ⇒ Adapters
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.
32 33 34 |
# File 'lib/hanami/providers/db/adapters.rb', line 32 def initialize @adapters = {} end |
Instance Attribute Details
#adapters ⇒ Object (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.
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.
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.
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.
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.
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.
60 61 62 |
# File 'lib/hanami/providers/db/adapters.rb', line 60 def new(key) self.class.new_adapter(key) end |