Sha256: 830495a9124ad4e3890df633245fe3d2154640038367e0cb2b9ee2b63c0e53a5

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 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.1.0 lib/jwk_loader/config/config.rb