Sha256: 1a10203290ee2f75dcee2675fddf9d6dbca2d89edc72431bb36ce7611435eb58

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

require 'singleton'

class LHC::Config
  include Singleton

  def initialize
    @endpoints = {}
    @placeholders = {}
  end

  def endpoint(name, url, options = {})
    name = name.to_sym
    raise 'Endpoint already exists for that name' if @endpoints[name]

    @endpoints[name] = LHC::Endpoint.new(url, options)
  end

  def endpoints
    @endpoints.dup
  end

  def placeholder(name, value)
    name = name.to_sym
    raise 'Placeholder already exists for that name' if @placeholders[name]

    @placeholders[name] = value
  end

  def placeholders
    @placeholders.dup
  end

  def interceptors
    (@interceptors || []).dup
  end

  def interceptors=(interceptors)
    raise 'Default interceptors already set and can only be set once' if @interceptors

    @interceptors = interceptors
  end

  def reset
    @endpoints = {}
    @placeholders = {}
    @interceptors = nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lhc-14.0.0 lib/lhc/config.rb