class ConfigMapper::ConfigDict
Public Class Methods
new(entry_factory, key_validator = nil)
click to toggle source
# File lib/config_mapper/config_dict.rb, line 34 def initialize(entry_factory, key_validator = nil) @entry_factory = entry_factory @key_validator = key_validator @entries = {} end
Public Instance Methods
[](key)
click to toggle source
# File lib/config_mapper/config_dict.rb, line 40 def [](key) key = @key_validator.call(key) if @key_validator @entries[key] ||= @entry_factory.new end
config_errors()
click to toggle source
# File lib/config_mapper/config_dict.rb, line 53 def config_errors {}.tap do |errors| each do |key, value| prefix = "[#{key.inspect}]" next unless value.respond_to?(:config_errors) value.config_errors.each do |path, path_errors| errors["#{prefix}#{path}"] = path_errors end end end end
to_h()
click to toggle source
# File lib/config_mapper/config_dict.rb, line 45 def to_h {}.tap do |result| @entries.each do |key, value| result[key] = value.to_h end end end