class Config::Factory::Environment
Attributes
configs[R]
name[R]
Public Class Methods
load_file(path)
click to toggle source
# File lib/config/factory/environment.rb, line 20 def self.load_file(path) hash = YAML.load_file(path) raise IOError, "Unable to load YAML file #{path}" unless hash && hash.is_a?(Hash) load_hash(hash) end
load_hash(hash)
click to toggle source
# File lib/config/factory/environment.rb, line 26 def self.load_hash(hash) Environment.new(name: Environments::DEFAULT_ENVIRONMENT, configs: hash) end
new(name:, configs:)
click to toggle source
# File lib/config/factory/environment.rb, line 10 def initialize(name:, configs:) self.name = name self.configs = configs end
Public Instance Methods
args_for(config_name)
click to toggle source
# File lib/config/factory/environment.rb, line 15 def args_for(config_name) config_name = config_name.to_s unless config_name.is_a?(String) @configs[config_name] end
to_s()
click to toggle source
# File lib/config/factory/environment.rb, line 30 def to_s "#{self.class}: name = #{@name}, configs = #{@configs})" end
Private Instance Methods
configs=(v)
click to toggle source
# File lib/config/factory/environment.rb, line 41 def configs=(v) raise ArgumentError, "Environment configs #{v} must be a hash" unless v && v.is_a?(Hash) @configs = v end
name=(v)
click to toggle source
# File lib/config/factory/environment.rb, line 36 def name=(v) raise ArgumentError, "Environment name #{v} must be a symbol" unless v && v.is_a?(Symbol) @name = v end