Class: AppConfig

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

Direct Known Subclasses

Secrets

Defined Under Namespace

Classes: ParsingError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = "") ⇒ AppConfig

Returns a new instance of AppConfig.



32
33
34
# File 'lib/app_config.rb', line 32

def initialize(filename = "")
	@filename = filename.empty? ? AppConfig.default_filename : filename
end

Class Method Details

.config_path_for(env) ⇒ Object



17
18
19
# File 'lib/app_config.rb', line 17

def config_path_for(env)
	"config/#{env}/config.json"
end

.default_filenameObject



13
14
15
# File 'lib/app_config.rb', line 13

def default_filename
	config_path_for(Environment.environment)
end

.loadObject



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

def load
	new(app_config_path).load
end

Instance Method Details

#loadObject



36
37
38
39
40
# File 'lib/app_config.rb', line 36

def load
	config['environment']&.each do |key, value|
		ENV[key] = value.is_a?(Hash) || value.is_a?(Array) ? value.to_json : value.to_s
	end
end