Class: LHC::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

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

Instance Attribute Details

#scrubsObject

Returns the value of attribute scrubs.



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

def scrubs
  @scrubs
end

Instance Method Details

#default_scrubsObject



48
49
50
51
52
53
54
55
# File 'lib/lhc/config.rb', line 48

def default_scrubs
  {
    auth: [:bearer, :basic],
    params: [],
    headers: [],
    body: ['password', 'password_confirmation']
  }
end

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



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

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



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

def endpoints
  @endpoints.dup
end

#interceptorsObject



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

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

#interceptors=(interceptors) ⇒ Object



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

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

  @interceptors = interceptors
end

#placeholder(name, value) ⇒ Object



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

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

  @placeholders[name] = value
end

#placeholdersObject



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

def placeholders
  @placeholders.dup
end

#resetObject



57
58
59
60
61
62
# File 'lib/lhc/config.rb', line 57

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