Sha256: 9af2dc0eb9ba8161a7325598d2b63ba6b72ba4922dfe1876fa57aa41417679e2

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

module JwkLoader
  class Config
    class ConfigurationNotFound < JwkLoader::Error
      def initialize(key)
        super "Configuration for #{key} not available"
      end
    end

    def []=(key, value)
      registry[key] = value
    end

    def [](key)
      registry[key] || (raise ConfigurationNotFound, key)
    end

    def method_missing(name, *args)
      return send(:[]=, name.to_s[0..-2].to_sym, *args) if name.to_s.end_with?("=")

      send(:[], name, *args)
    end

    def respond_to_missing?(_name, _include_private)
      true
    end

    private

    def registry
      @registry ||= {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jwk-loader-1.0.0 lib/jwk_loader/config/config.rb