Sha256: 6e23c47df57a56361a4da16641c6f50787a56989264c819057934b745cbd41f5
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Config module Factory class Environment attr_reader :name def initialize(name:, configs:) self.name = name self.configs = configs end def args_for(config_name) config_name = config_name.to_s unless config_name.is_a?(String) @configs[config_name] end def self.load_file(path) hash = YAML.load_file(path) fail IOError, "Unable to load YAML file #{path}" unless hash && hash.is_a?(Hash) load_hash(hash) end def self.load_hash(hash) Environment.new(name: Environments::DEFAULT_ENVIRONMENT, configs: hash) end def to_s "#{self.class}: name = #{@name}, configs = #{@configs})" end private def name=(v) fail ArgumentError, "Environment name #{v} must be a symbol" unless v && v.is_a?(Symbol) @name = v end def configs=(v) fail ArgumentError, "Environment configs #{v} must be a hash" unless v && v.is_a?(Hash) @configs = v end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
config-factory-0.0.6 | lib/config/factory/environment.rb |