Class: RubyAPI::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
8
# File 'lib/fastrb/config.rb', line 5

def initialize
  @environment = ENV.fetch("FASTRB_ENV", "development")
  @settings = default_settings
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



3
4
5
# File 'lib/fastrb/config.rb', line 3

def environment
  @environment
end

#settingsObject

Returns the value of attribute settings.



3
4
5
# File 'lib/fastrb/config.rb', line 3

def settings
  @settings
end

Instance Method Details

#get(key) ⇒ Object



20
21
22
# File 'lib/fastrb/config.rb', line 20

def get(key)
  @settings[key]
end

#load_environment_config(app_root = Dir.pwd) ⇒ Object



10
11
12
13
14
# File 'lib/fastrb/config.rb', line 10

def load_environment_config(app_root = Dir.pwd)
  config_file = File.join(app_root, "config", "environments", "#{@environment}.rb")
  return unless File.exist?(config_file)
  instance_eval(File.read(config_file))
end

#setting(key, value) ⇒ Object



16
17
18
# File 'lib/fastrb/config.rb', line 16

def setting(key, value)
  @settings[key] = value
end