Class: PicoApi::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/pico_api/database.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.containerObject

Returns the value of attribute container.



9
10
11
# File 'lib/pico_api/database.rb', line 9

def container
  @container
end

Class Method Details

.setup!Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pico_api/database.rb', line 11

def setup!
  database_config = PicoApi.configuration.db_config.deep_symbolize_keys
  logger = PicoApi.configuration.logger
  gateways = database_config.keys

  configs = create_config(gateways, database_config)
  cont = ROM.container(**configs) { |config| yield config if block_given? }

  gateways.each { |gateway| cont.gateways[gateway].use_logger(logger) } if logger

  @container = cont
end