Class: Hanami::Providers::DB::SQLAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/hanami/providers/db/sql_adapter.rb

Overview

Since:

  • 2.2.0

Instance Method Summary collapse

Methods inherited from Adapter

#gateway_cache_keys, #initialize, #plugin, #plugins, #skip_defaults

Constructor Details

This class inherits a constructor from Hanami::Providers::DB::Adapter

Instance Method Details

#clearObject

Since:

  • 2.2.0



93
94
95
96
# File 'lib/hanami/providers/db/sql_adapter.rb', line 93

def clear
  config.extensions = nil
  super
end

#configure_for_database(database_url) ⇒ 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



40
41
42
43
44
45
# File 'lib/hanami/providers/db/sql_adapter.rb', line 40

def configure_for_database(database_url)
  return if skip_defaults?

  configure_plugins
  configure_extensions(database_url)
end

#configure_from_adapter(other_adapter) ⇒ 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



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hanami/providers/db/sql_adapter.rb', line 26

def configure_from_adapter(other_adapter)
  super

  return if skip_defaults?

  # As part of gateway configuration, every gateway will receive the "any adapter" here,
  # which is a plain `Adapter`, not an `SQLAdapter`. Its configuration will have been merged
  # by `super`, so no further work is required.
  return unless other_adapter.is_a?(self.class)

  extensions.concat(other_adapter.extensions).uniq! unless skip_defaults?(:extensions)
end

#extension(*extensions) ⇒ Object

Since:

  • 2.2.0



15
16
17
# File 'lib/hanami/providers/db/sql_adapter.rb', line 15

def extension(*extensions)
  self.extensions.concat(extensions).uniq!
end

#extensionsObject

Since:

  • 2.2.0



21
22
23
# File 'lib/hanami/providers/db/sql_adapter.rb', line 21

def extensions
  config.extensions ||= []
end

#gateway_optionsObject

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



87
88
89
# File 'lib/hanami/providers/db/sql_adapter.rb', line 87

def gateway_options
  {extensions: extensions}
end