Class: YAPI::Config
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- YAPI::Config
- Defined in:
- lib/yapi/config.rb
Constant Summary collapse
- SETTINGS_KEYS =
%w[root headers output].freeze
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(filename) ⇒ Config
constructor
A new instance of Config.
- #output_headers? ⇒ Boolean
- #request(route_name) ⇒ Object
- #requests ⇒ Object
- #root ⇒ Object
- #session ⇒ Object
Constructor Details
#initialize(filename) ⇒ Config
12 13 14 |
# File 'lib/yapi/config.rb', line 12 def initialize(filename) super(YAML.load(File.read(filename))) end |
Instance Method Details
#headers ⇒ Object
28 29 30 |
# File 'lib/yapi/config.rb', line 28 def headers fetch("headers", {}) end |
#output_headers? ⇒ Boolean
16 17 18 |
# File 'lib/yapi/config.rb', line 16 def output_headers? fetch("output", {}).fetch("headers", true) end |
#request(route_name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/yapi/config.rb', line 32 def request(route_name) req = self[route_name] req.merge!("url" => URI.join(root, req["path"])) req["headers"] = headers.merge(req.fetch("headers", {})) YAPI::Request.new(req) end |
#requests ⇒ Object
39 40 41 |
# File 'lib/yapi/config.rb', line 39 def requests keys - SETTINGS_KEYS end |
#root ⇒ Object
24 25 26 |
# File 'lib/yapi/config.rb', line 24 def root self["root"] end |
#session ⇒ Object
20 21 22 |
# File 'lib/yapi/config.rb', line 20 def session self["session"] end |