Class: Core::Config
Overview
configuration wrapper
Instance Attribute Summary collapse
-
#config_name ⇒ Object
readonly
Returns the value of attribute config_name.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #key?(key) ⇒ Boolean
Methods included from ConfigHelper
#get_b!, #get_f!, #get_i!, #get_s!, #get_x!
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/svcbase/config.rb', line 20 def initialize @config_name = ENV['SA_ENV'] ||= 'local' @config = {} ['base', @config_name].each do |name| f = Pathname.new(CONFIG_DIR).join("#{name}.yml") c = YAML.load_file(f) next unless c @config.deep_merge!(c) rescue StandardError => e STDERR.puts "Error reading config file #{e}" raise end end |
Instance Attribute Details
#config_name ⇒ Object (readonly)
Returns the value of attribute config_name.
18 19 20 |
# File 'lib/svcbase/config.rb', line 18 def config_name @config_name end |
Instance Method Details
#[](key) ⇒ Object
38 39 40 |
# File 'lib/svcbase/config.rb', line 38 def [](key) ENV.key?(key) ? ENV[key] : @config[key] end |
#key?(key) ⇒ Boolean
34 35 36 |
# File 'lib/svcbase/config.rb', line 34 def key?(key) ENV.key?(key) || @config.key?(key) end |