Class: Config::Factory::Environment
- Inherits:
-
Object
- Object
- Config::Factory::Environment
- Defined in:
- lib/config/factory/environment.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #args_for(config_name) ⇒ Object
-
#initialize(name:, configs:) ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize(name:, configs:) ⇒ Environment
Returns a new instance of Environment.
7 8 9 10 |
# File 'lib/config/factory/environment.rb', line 7 def initialize(name:, configs:) self.name = name self.configs = configs end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/config/factory/environment.rb', line 5 def name @name end |
Class Method Details
.load_file(path) ⇒ Object
17 18 19 20 |
# File 'lib/config/factory/environment.rb', line 17 def self.load_file(path) hash = YAML.load_file(path) load_hash(hash) end |
.load_hash(hash) ⇒ Object
22 23 24 |
# File 'lib/config/factory/environment.rb', line 22 def self.load_hash(hash) Environment.new(name: Environments::DEFAULT_ENVIRONMENT, configs: hash) end |
Instance Method Details
#args_for(config_name) ⇒ Object
12 13 14 15 |
# File 'lib/config/factory/environment.rb', line 12 def args_for(config_name) config_name = config_name.to_s unless config_name.is_a?(String) @configs[config_name] end |