Class: OasParser::Path
- Inherits:
-
Object
- Object
- OasParser::Path
- Defined in:
- lib/oas_parser_reborn/path.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#path ⇒ Object
Returns the value of attribute path.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
- #callback ⇒ Object
- #definition ⇒ Object
- #endpoint_by_method(method) ⇒ Object
- #endpoints ⇒ Object
-
#initialize(owner, path, raw) ⇒ Path
constructor
A new instance of Path.
- #parameter_keys ⇒ Object
- #parameters ⇒ Object
Constructor Details
#initialize(owner, path, raw) ⇒ Path
Returns a new instance of Path.
5 6 7 8 9 |
# File 'lib/oas_parser_reborn/path.rb', line 5 def initialize(owner, path, raw) @owner = owner @path = path @raw = raw end |
Instance Attribute Details
#owner ⇒ Object
Returns the value of attribute owner.
3 4 5 |
# File 'lib/oas_parser_reborn/path.rb', line 3 def owner @owner end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/oas_parser_reborn/path.rb', line 3 def path @path end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/oas_parser_reborn/path.rb', line 3 def raw @raw end |
Instance Method Details
#callback ⇒ Object
41 42 43 |
# File 'lib/oas_parser_reborn/path.rb', line 41 def callback owner if owner.class == OasParser::Callback end |
#definition ⇒ Object
37 38 39 |
# File 'lib/oas_parser_reborn/path.rb', line 37 def definition owner if owner.class == OasParser::Definition end |
#endpoint_by_method(method) ⇒ Object
20 21 22 23 24 |
# File 'lib/oas_parser_reborn/path.rb', line 20 def endpoint_by_method(method) definition = raw[method] raise OasParser::MethodNotFound.new("HTTP method not found: '#{method}'") unless definition OasParser::Endpoint.new(self, method, definition) end |
#endpoints ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/oas_parser_reborn/path.rb', line 11 def endpoints a = raw.map do |method, definition| next unless %w[get head post put patch delete trace options].include? method OasParser::Endpoint.new(self, method, definition) end a.compact end |
#parameter_keys ⇒ Object
26 27 28 |
# File 'lib/oas_parser_reborn/path.rb', line 26 def parameter_keys path.scan(/{(.+?)}/).flatten end |