Sha256: 477a1c00800b38b3a933a8f6d3a535757d56ac81222c813af4794c18463c216b
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module Config module Factory class Environment attr_reader :name attr_reader :configs 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
config-factory-0.0.9 | lib/config/factory/environment.rb |
config-factory-0.0.8 | lib/config/factory/environment.rb |
config-factory-0.0.7 | lib/config/factory/environment.rb |