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.



6
7
8
9
# File 'lib/lhc/config.rb', line 6

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

Instance Method Details

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



11
12
13
14
15
# File 'lib/lhc/config.rb', line 11

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



17
18
19
# File 'lib/lhc/config.rb', line 17

def endpoints
  @endpoints.dup
end

#interceptorsObject



31
32
33
# File 'lib/lhc/config.rb', line 31

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

#interceptors=(interceptors) ⇒ Object



35
36
37
38
# File 'lib/lhc/config.rb', line 35

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

#placeholder(name, value) ⇒ Object



21
22
23
24
25
# File 'lib/lhc/config.rb', line 21

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

#placeholdersObject



27
28
29
# File 'lib/lhc/config.rb', line 27

def placeholders
  @placeholders.dup
end

#resetObject



40
41
42
43
44
# File 'lib/lhc/config.rb', line 40

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