Class: Hanami::Providers::DB::Gateway
- Inherits:
-
Object
- Object
- Hanami::Providers::DB::Gateway
show all
- Includes:
- Dry::Configurable, Dry::Core::Constants
- Defined in:
- lib/hanami/providers/db/gateway.rb
Overview
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/hanami/providers/db/gateway.rb', line 73
def method_missing(name, *args, &block)
if config.respond_to?(name)
config.public_send(name, *args, &block)
else
super
end
end
|
Instance Method Details
#adapter(name = Undefined) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/hanami/providers/db/gateway.rb', line 22
def adapter(name = Undefined)
return config.adapter if name.eql?(Undefined)
if block_given?
config.adapter_name = name
adapter = (config.adapter ||= Adapters.new_adapter(name))
yield adapter
adapter
else
config.adapter_name = adapter_name
end
end
|
#cache_keys ⇒ 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.
67
68
69
|
# File 'lib/hanami/providers/db/gateway.rb', line 67
def cache_keys
[config.database_url, config.connection_options, config.adapter.gateway_cache_keys]
end
|
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.
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/hanami/providers/db/gateway.rb', line 55
def configure_adapter(default_adapters)
default_adapter = default_adapters.find(config.adapter_name)
config.adapter ||= default_adapter.dup
config.adapter.configure_from_adapter(default_adapter)
config.adapter.configure_for_database(config.database_url)
self
end
|
#connection_options(**options) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/hanami/providers/db/gateway.rb', line 40
def connection_options(**options)
if options.any?
config.connection_options.merge!(options)
end
config.connection_options
end
|
#options ⇒ Object
50
51
52
|
# File 'lib/hanami/providers/db/gateway.rb', line 50
def options
{**connection_options, **config.adapter.gateway_options}
end
|