Class: Inspector
- Inherits:
-
Object
- Object
- Inspector
- Defined in:
- lib/rspec/openapi/extractors/hanami.rb
Overview
Instance Attribute Summary collapse
-
#inflector ⇒ Object
Returns the value of attribute inflector.
-
#routes ⇒ Object
Returns the value of attribute routes.
Instance Method Summary collapse
- #add_route(route) ⇒ Object
- #call(verb, path) ⇒ Object
-
#initialize(routes: []) ⇒ Inspector
constructor
A new instance of Inspector.
Constructor Details
#initialize(routes: []) ⇒ Inspector
Returns a new instance of Inspector.
10 11 12 13 |
# File 'lib/rspec/openapi/extractors/hanami.rb', line 10 def initialize(routes: []) @routes = routes @inflector = Dry::Inflector.new end |
Instance Attribute Details
#inflector ⇒ Object
Returns the value of attribute inflector.
8 9 10 |
# File 'lib/rspec/openapi/extractors/hanami.rb', line 8 def inflector @inflector end |
#routes ⇒ Object
Returns the value of attribute routes.
8 9 10 |
# File 'lib/rspec/openapi/extractors/hanami.rb', line 8 def routes @routes end |
Instance Method Details
#add_route(route) ⇒ Object
15 16 17 |
# File 'lib/rspec/openapi/extractors/hanami.rb', line 15 def add_route(route) routes.push(route) end |
#call(verb, path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspec/openapi/extractors/hanami.rb', line 19 def call(verb, path) route = routes.find { |r| r.http_method == verb && r.path == path } if route.to.is_a?(Proc) { tags: [], summary: "#{verb} #{path}", } else data = route.to.split('.') { tags: [inflector.classify(data[0])], summary: data[1], } end end |