Sha256: 94e8fcacbbb4141fe42d0f67592e88cb7db0dc76463a7a874fedca4f283bc804

Contents?: true

Size: 918 Bytes

Versions: 37

Compression:

Stored size: 918 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

37 entries across 37 versions & 1 rubygems

Version Path
lhc-13.2.0 lib/lhc/config.rb
lhc-13.1.0 lib/lhc/config.rb
lhc-13.0.0 lib/lhc/config.rb
lhc-12.3.0 lib/lhc/config.rb
lhc-12.2.1 lib/lhc/config.rb
lhc-12.2.0 lib/lhc/config.rb
lhc-12.1.3 lib/lhc/config.rb
lhc-12.1.2 lib/lhc/config.rb
lhc-12.1.1 lib/lhc/config.rb
lhc-12.1.0 lib/lhc/config.rb
lhc-12.0.3 lib/lhc/config.rb
lhc-12.0.2 lib/lhc/config.rb
lhc-12.0.1 lib/lhc/config.rb
lhc-12.0.0 lib/lhc/config.rb
lhc-11.2.0 lib/lhc/config.rb
lhc-11.1.1 lib/lhc/config.rb
lhc-11.1.0 lib/lhc/config.rb
lhc-11.0.2 lib/lhc/config.rb
lhc-11.0.1 lib/lhc/config.rb
lhc-11.0.0 lib/lhc/config.rb