Class: DHC::Config
Instance Method Summary collapse
- #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.
8 9 10 11 |
# File 'lib/dhc/config.rb', line 8 def initialize @endpoints = {} @placeholders = {} end |
Instance Method Details
#endpoint(name, url, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/dhc/config.rb', line 13 def endpoint(name, url, = {}) name = name.to_sym raise 'Endpoint already exists for that name' if @endpoints[name] @endpoints[name] = DHC::Endpoint.new(url, ) end |
#endpoints ⇒ Object
19 20 21 |
# File 'lib/dhc/config.rb', line 19 def endpoints @endpoints.dup end |
#interceptors ⇒ Object
33 34 35 |
# File 'lib/dhc/config.rb', line 33 def interceptors (@interceptors || []).dup end |
#interceptors=(interceptors) ⇒ Object
37 38 39 40 |
# File 'lib/dhc/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/dhc/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 |
#placeholders ⇒ Object
29 30 31 |
# File 'lib/dhc/config.rb', line 29 def placeholders @placeholders.dup end |
#reset ⇒ Object
42 43 44 45 46 |
# File 'lib/dhc/config.rb', line 42 def reset @endpoints = {} @placeholders = {} @interceptors = nil end |