Class: RailsOpenapiGen::Parsers::Jbuilder::Processors::ArrayProcessor
- Inherits:
-
BaseProcessor
- Object
- Parser::AST::Processor
- BaseProcessor
- RailsOpenapiGen::Parsers::Jbuilder::Processors::ArrayProcessor
- Defined in:
- lib/rails-openapi-gen/parsers/jbuilder/processors/array_processor.rb
Constant Summary collapse
- CallDetectors =
Alias for shorter reference to call detectors
RailsOpenapiGen::Parsers::Jbuilder::CallDetectors
- JbuilderParser =
Alias for shorter reference to JbuilderParser
RailsOpenapiGen::Parsers::Jbuilder::JbuilderParser
Class Method Summary collapse
-
.composite_processor_class ⇒ Object
Lazy load CompositeProcessor to avoid circular dependency.
Instance Method Summary collapse
-
#on_block(node) ⇒ void
Processes block nodes for array iterations.
-
#on_send(node) ⇒ void
Processes method call nodes for array-related operations.
Methods inherited from BaseProcessor
#handler_missing, #initialize, #on_if, #partials, #properties
Constructor Details
This class inherits a constructor from RailsOpenapiGen::Parsers::Jbuilder::Processors::BaseProcessor
Class Method Details
.composite_processor_class ⇒ Object
Lazy load CompositeProcessor to avoid circular dependency
13 14 15 |
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/array_processor.rb', line 13 def self.composite_processor_class RailsOpenapiGen::Parsers::Jbuilder::Processors::CompositeProcessor end |
Instance Method Details
#on_block(node) ⇒ void
This method returns an undefined value.
Processes block nodes for array iterations
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/array_processor.rb', line 40 def on_block(node) send_node, args_node, = node.children receiver, method_name, = send_node.children if CallDetectors::ArrayCallDetector.array_call?(receiver, method_name) # This is json.array! block process_array_block(node) elsif CallDetectors::JsonCallDetector.json_property?(receiver, method_name) && method_name != :array! # Check if this is an array iteration block (has block arguments) if args_node && args_node.type == :args && args_node.children.any? # This is an array iteration block like json.tags @tags do |tag| process_array_iteration_block(node, method_name.to_s) else super end else super end end |
#on_send(node) ⇒ void
This method returns an undefined value.
Processes method call nodes for array-related operations
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/array_processor.rb', line 20 def on_send(node) receiver, method_name, *args = node.children if CallDetectors::ArrayCallDetector.array_call?(receiver, method_name) # Check if this is an array with partial if args.any? && args.any? do |arg| arg.type == :hash && CallDetectors::ArrayCallDetector.has_partial_key?(arg) end process_array_with_partial(node, args) else process_array_property(node) end end super end |