Class: Config::Factory::Environment

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

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