Module: OllamaAgent::Topology::Extractors::RubySemanticExtractor::ConcernBody

Defined in:
lib/ollama_agent/topology/extractors/ruby_semantic_extractor/concern_body.rb

Overview

Detects ActiveSupport::Concern usage inside a class/module body.

Class Method Summary collapse

Class Method Details

.concern?(body) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ollama_agent/topology/extractors/ruby_semantic_extractor/concern_body.rb', line 15

def concern?(body)
  statement_items(body).any? { |stmt| concern_call?(stmt) }
end

.concern_call?(stmt) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ollama_agent/topology/extractors/ruby_semantic_extractor/concern_body.rb', line 25

def concern_call?(stmt)
  stmt.is_a?(Prism::CallNode) && concern_invocation?(stmt)
end

.concern_fqcn?(arg) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/ollama_agent/topology/extractors/ruby_semantic_extractor/concern_body.rb', line 37

def concern_fqcn?(arg)
  fq = OllamaAgent::RubyIndex::Naming.full_constant_path(arg).to_s
  fq == "ActiveSupport::Concern" || fq.end_with?("::ActiveSupport::Concern")
end

.concern_invocation?(call) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/ollama_agent/topology/extractors/ruby_semantic_extractor/concern_body.rb', line 29

def concern_invocation?(call)
  return false unless %i[extend include].include?(call.name)
  return false if call.receiver

  arg = call.arguments&.arguments&.first
  concern_fqcn?(arg)
end

.statement_items(body) ⇒ Object



19
20
21
22
23
# File 'lib/ollama_agent/topology/extractors/ruby_semantic_extractor/concern_body.rb', line 19

def statement_items(body)
  return [] unless body.is_a?(Prism::StatementsNode)

  Array(body.body)
end