Class: RubyAPI::Config
- Inherits:
-
Object
- Object
- RubyAPI::Config
- Defined in:
- lib/rubyapi/config.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_environment_config(app_root = Dir.pwd) ⇒ Object
- #setting(key, value) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 8 |
# File 'lib/rubyapi/config.rb', line 5 def initialize @environment = ENV.fetch("RUBYAPI_ENV", "development") @settings = default_settings end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/rubyapi/config.rb', line 3 def environment @environment end |
#settings ⇒ Object
Returns the value of attribute settings.
3 4 5 |
# File 'lib/rubyapi/config.rb', line 3 def settings @settings end |
Instance Method Details
#get(key) ⇒ Object
20 21 22 |
# File 'lib/rubyapi/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/rubyapi/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/rubyapi/config.rb', line 16 def setting(key, value) @settings[key] = value end |