Sha256: fccdd5a20e62940fb791d4273d6802eca1fa7bd478204036515b56c059a9422c

Contents?: true

Size: 652 Bytes

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
dry-system-0.17.0 lib/dry/system/components/config.rb
dry-system-0.15.0 lib/dry/system/components/config.rb
dry-system-0.14.1 lib/dry/system/components/config.rb
dry-system-0.14.0 lib/dry/system/components/config.rb
dry-system-0.13.2 lib/dry/system/components/config.rb
dry-system-0.13.1 lib/dry/system/components/config.rb
dry-system-0.13.0 lib/dry/system/components/config.rb