Class: LHC::Config
Instance Attribute Summary collapse
-
#scrubs ⇒ Object
Returns the value of attribute scrubs.
Instance Method Summary collapse
- #default_scrubs ⇒ Object
- #endpoint(name, url, options = {}) ⇒ Object
- #endpoints ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #interceptors ⇒ Object
- #interceptors=(interceptors) ⇒ Object
- #placeholder(name, value) ⇒ Object
- #placeholders ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Config
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
#scrubs ⇒ Object
Returns the value of attribute scrubs.
8 9 10 |
# File 'lib/lhc/config.rb', line 8 def scrubs @scrubs end |
Instance Method Details
#default_scrubs ⇒ Object
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, = {}) name = name.to_sym raise 'Endpoint already exists for that name' if @endpoints[name] @endpoints[name] = LHC::Endpoint.new(url, ) end |
#endpoints ⇒ Object
23 24 25 |
# File 'lib/lhc/config.rb', line 23 def endpoints @endpoints.dup end |
#interceptors ⇒ Object
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 |
#placeholders ⇒ Object
34 35 36 |
# File 'lib/lhc/config.rb', line 34 def placeholders @placeholders.dup end |
#reset ⇒ Object
57 58 59 60 61 62 |
# File 'lib/lhc/config.rb', line 57 def reset @endpoints = {} @placeholders = {} @interceptors = nil @scrubs = default_scrubs end |