Sha256: 9635c004bf36f976252356aa9fa5b6a26bb6a38ff2aa545838e6e424360eb030

Contents?: true

Size: 652 Bytes

Versions: 9

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module Dry
  module System
    module Components
      class Config
        def self.new(&block)
          config = super
          yield(config) if block_given?
          config
        end

        def initialize
          @settings = {}
        end

        def to_hash
          @settings
        end

        private

        def method_missing(meth, value = nil)
          if meth.to_s.end_with?("=")
            @settings[meth.to_s.gsub("=", "").to_sym] = value
          elsif @settings.key?(meth)
            @settings[meth]
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dry-system-0.22.0 lib/dry/system/components/config.rb
dry-system-0.21.0 lib/dry/system/components/config.rb
dry-system-0.20.0 lib/dry/system/components/config.rb
dry-system-0.19.2 lib/dry/system/components/config.rb
dry-system-0.18.2 lib/dry/system/components/config.rb
dry-system-0.19.1 lib/dry/system/components/config.rb
dry-system-0.19.0 lib/dry/system/components/config.rb
dry-system-0.18.1 lib/dry/system/components/config.rb
dry-system-0.18.0 lib/dry/system/components/config.rb