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
- .concern?(body) ⇒ Boolean
- .concern_call?(stmt) ⇒ Boolean
- .concern_fqcn?(arg) ⇒ Boolean
- .concern_invocation?(call) ⇒ Boolean
- .statement_items(body) ⇒ Object
Class Method Details
.concern?(body) ⇒ 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
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
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
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 |