Sha256: 25d1a4547f3ba89a40ec37739d1be5e5574e3bbc3ba33337ab385ade4676c20d

Contents?: true

Size: 887 Bytes

Versions: 19

Compression:

Stored size: 887 Bytes

Contents

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

19 entries across 19 versions & 1 rubygems

Version Path
lhc-10.1.2 lib/lhc/config.rb
lhc-10.1.1 lib/lhc/config.rb
lhc-10.1.0 lib/lhc/config.rb
lhc-10.0.2 lib/lhc/config.rb
lhc-9.4.4 lib/lhc/config.rb
lhc-10.0.1 lib/lhc/config.rb
lhc-10.0.0 lib/lhc/config.rb
lhc-9.4.3 lib/lhc/config.rb
lhc-9.4.2 lib/lhc/config.rb
lhc-9.4.1 lib/lhc/config.rb
lhc-9.4.0 lib/lhc/config.rb
lhc-9.3.1 lib/lhc/config.rb
lhc-9.3.0 lib/lhc/config.rb
lhc-3.8.1 lib/lhc/config.rb
lhc-3.8.0 lib/lhc/config.rb
lhc-3.7.3 lib/lhc/config.rb
lhc-3.7.2 lib/lhc/config.rb
lhc-3.7.2.1 lib/lhc/config.rb
lhc-3.7.1 lib/lhc/config.rb