Class: OpenapiBlocks::Routing::Extractor

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

Overview

rubocop:disable Style/Documentation,Metrics/ClassLength

Constant Summary collapse

IGNORED_CONTROLLERS =
%w[
  rails/
  action_mailbox/
  active_storage/
  openapi_blocks/
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app = Rails.application) ⇒ Extractor

Returns a new instance of Extractor.



15
16
17
# File 'lib/openapi_blocks/routing/extractor.rb', line 15

def initialize(app = Rails.application)
  @app = app
end

Instance Method Details

#extractObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openapi_blocks/routing/extractor.rb', line 19

def extract
  routes.each_with_object({}) do |operation, hash|
    next unless operation.valid?

    hash[operation.path] ||= {}

    operation.verbs.each do |verb|
      hash[operation.path][verb] = build_operation(operation)
    end
  end
end