Class: RailsAiBridge::Introspectors::ControllerIntrospector::FilterExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/introspectors/controller_introspector/filter_extractor.rb

Overview

Extracts before/after/around filter metadata from an ActionController class.

Walks the controller and its ancestors' _process_action_callbacks chains so inherited before_action / after_action filters (e.g. parent auth) are attributed to the class that defined them. Filters whose :only / :except conditions match none of the controller's actions are omitted.

Constant Summary collapse

FRAMEWORK_PREFIXES =
%w[ActionController:: AbstractController:: ActionDispatch::].freeze

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ FilterExtractor

Returns a new instance of FilterExtractor.

Parameters:

  • controller (Class) —

    ActionController class to inspect



16
17
18
# File 'lib/rails_ai_bridge/introspectors/controller_introspector/filter_extractor.rb', line 16

def initialize(controller)
  @controller = controller
end

Instance Method Details

#call ⇒ Array<Hash>

Returns list of filter descriptors.

Returns:

  • (Array<Hash>) —

    list of filter descriptors



21
22
23
24
25
26
# File 'lib/rails_ai_bridge/introspectors/controller_introspector/filter_extractor.rb', line 21

def call
  effective_callbacks.filter_map { |cb| build_filter(cb) if valid_filter?(cb) }
                     .select { |filter| applicable?(filter) }
rescue StandardError
  []
end