Class: Lagoon::Analyzer::ActionControllerAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/lagoon/analyzer/action_controller_analyzer.rb

Overview

Analyzes ActionController classes to extract metadata including methods and inheritance

Instance Method Summary collapse

Instance Method Details

#analyze_controller(controller, options = {}) ⇒ Hash

Analyze a single controller and return its metadata

Parameters:

  • controller (Class)

    ActionController class

  • options (Hash) (defaults to: {})

    Analysis options

Returns:

  • (Hash)

    Controller metadata



13
14
15
16
17
18
19
20
# File 'lib/lagoon/analyzer/action_controller_analyzer.rb', line 13

def analyze_controller(controller, options = {})
  {
    name: controller.name,
    abstract: abstract_controller?(controller),
    attributes: [],
    methods: extract_methods(controller, options)
  }
end

#extract_inheritance(controller, include_framework_base: false) ⇒ Array<Hash>

Extract inheritance relationship from a controller

Parameters:

  • controller (Class)

    ActionController class

Returns:

  • (Array<Hash>)

    Inheritance metadata (empty or single element)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lagoon/analyzer/action_controller_analyzer.rb', line 26

def extract_inheritance(controller, include_framework_base: false)
  return [] if controller.superclass == ActionController::Base && !include_framework_base
  return [] unless controller.superclass.name
  return [] if !include_framework_base && controller.superclass.name.start_with?('ActionController::')

  [{
    source: controller.superclass.name,
    target: controller.name,
    type: :inheritance,
    label: nil
  }]
rescue NameError
  []
end