Class: LHC::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/lhc/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.


8
9
10
11
# File 'lib/lhc/config.rb', line 8

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

Instance Method Details

#endpoint(name, url, options = {}) ⇒ Object


13
14
15
16
17
# File 'lib/lhc/config.rb', line 13

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

#endpointsObject


19
20
21
# File 'lib/lhc/config.rb', line 19

def endpoints
  @endpoints.dup
end

#interceptorsObject


33
34
35
# File 'lib/lhc/config.rb', line 33

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

#interceptors=(interceptors) ⇒ Object


37
38
39
40
# File 'lib/lhc/config.rb', line 37

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

#placeholder(name, value) ⇒ Object


23
24
25
26
27
# File 'lib/lhc/config.rb', line 23

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

#placeholdersObject


29
30
31
# File 'lib/lhc/config.rb', line 29

def placeholders
  @placeholders.dup
end

#resetObject


42
43
44
45
46
# File 'lib/lhc/config.rb', line 42

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