Class: Pokeedex::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pokeedex/configuration.rb

Overview

Class that holds the configuration of the gem and the database connection information and methods to connect to the database and run the migrations if needed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
# File 'lib/pokeedex/configuration.rb', line 18

def initialize
  @db_name = 'pokeedex_local.sqlite3'
end

Instance Attribute Details

#db_nameObject

The name of the database file to use for the gem (default: pokeedex_local.sqlite3)



12
13
14
# File 'lib/pokeedex/configuration.rb', line 12

def db_name
  @db_name
end

#db_pathObject

Return the path to the database file to use for the gem (default: /path/to/pokeedex/db/pokeedex_local.sqlite3)



31
32
33
# File 'lib/pokeedex/configuration.rb', line 31

def db_path
  @db_path ||= File.join(Pokeedex.root_path, 'lib', 'pokeedex', 'db', db_name)
end

Instance Method Details

#db_connectionObject

Return the database connection to the database file to use for the gem (default: /path/to/pokeedex/db/pokeedex_local.sqlite3)



37
38
39
# File 'lib/pokeedex/configuration.rb', line 37

def db_connection
  Sequel.sqlite(db_path)
end