Class: SwaggerDocsGenerator::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger_docs_generator/extractor.rb

Overview

# Extractor routes info

Give information about routes

Instance Method Summary collapse

Constructor Details

#initialize(controller, action) ⇒ Extractor

Returns a new instance of Extractor.



8
9
10
11
12
# File 'lib/swagger_docs_generator/extractor.rb', line 8

def initialize(controller, action)
  @action = action
  @controller = controller
  @routes = Rails.application.routes.routes
end

Instance Method Details

#pathObject



20
21
22
23
24
# File 'lib/swagger_docs_generator/extractor.rb', line 20

def path
  router do |route|
    route.path.spec.to_s.gsub('(.:format)', '.json').gsub(':id', '{id}')
  end
end

#verbObject



14
15
16
17
18
# File 'lib/swagger_docs_generator/extractor.rb', line 14

def verb
  router do |route|
    route.verb.source.to_s.delete('$' + '^')
  end
end