Sha256: e264ff278dd61e264abd763fc5ba4b20962f44860cdc08a0a24f4f7f1c520412

Contents?: true

Size: 621 Bytes

Versions: 9

Compression:

Stored size: 621 Bytes

Contents

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.12.0 lib/dry/system/components/config.rb
dry-system-0.11.0 lib/dry/system/components/config.rb
dry-system-0.10.1 lib/dry/system/components/config.rb
dry-system-0.10.0 lib/dry/system/components/config.rb
dry-system-0.9.2 lib/dry/system/components/config.rb
dry-system-0.9.1 lib/dry/system/components/config.rb
dry-system-0.9.0 lib/dry/system/components/config.rb
dry-system-0.8.1 lib/dry/system/components/config.rb
dry-system-0.8.0 lib/dry/system/components/config.rb