Sha256: 941209109ee210aad190c20c641ffaba0ef8389e210e4308f2c644eb21950b54
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
# frozen_string_literal: true require "concurrent/map" require "dry/core/equalizer" require "dry/configurable/constants" module Dry module Configurable # A settings map # # @api private class Settings include Dry::Equalizer(:elements) include Enumerable # @api private attr_reader :elements # @api private def initialize(elements = EMPTY_ARRAY) initialize_elements(elements) end # @api private def <<(setting) elements[setting.name] = setting self end # @api private def [](name) elements[name] end # @api private def key?(name) keys.include?(name) end # @api private def keys elements.keys end # @api private def each(&block) elements.values.each(&block) end # @api private def pristine self.class.new(map(&:pristine)) end # @api private def finalize!(freeze_values: false) each { |element| element.finalize!(freeze_values: freeze_values) } freeze end private # @api private def initialize_copy(source) initialize_elements(source.map(&:dup)) end # @api private def initialize_elements(elements) @elements = elements.each_with_object(Concurrent::Map.new) { |s, m| m[s.name] = s } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-configurable-0.15.0 | lib/dry/configurable/settings.rb |