Class: RailsOpenapiGen::Parsers::Jbuilder::Processors::BaseProcessor

Inherits:
Parser::AST::Processor
  • Object
show all
Defined in:
lib/rails-openapi-gen/parsers/jbuilder/processors/base_processor.rb

Constant Summary collapse

JbuilderParser =

Alias for shorter reference to JbuilderParser

RailsOpenapiGen::Parsers::Jbuilder::JbuilderParser

Instance Method Summary collapse

Constructor Details

#initialize(file_path, property_parser) ⇒ BaseProcessor

Initializes base processor



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/base_processor.rb', line 23

def initialize(file_path, property_parser)
  super() # Call parent initialize first, with no arguments
  @file_path = file_path
  @property_parser = property_parser
  @properties = []
  @partials = []
  @block_stack = []
  @current_object_properties = []
  @nested_objects = {}
  @conditional_stack = []
end

Instance Method Details

#handler_missing(node) ⇒ Parser::AST::Node?

Handler for missing node types



66
67
68
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/base_processor.rb', line 66

def handler_missing(node)
  node
end

#on_if(node) ⇒ void

This method returns an undefined value.

Processes if statements to track conditional properties



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/base_processor.rb', line 46

def on_if(node)
  # Check if this if statement has a conditional comment
  comment_data = find_comment_for_node(node)

  if comment_data && comment_data[:conditional]
    @conditional_stack.push(true)
    super
    @conditional_stack.pop
  else
    super
  end
end

#partialsObject

Ensure partials array is always initialized



16
17
18
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/base_processor.rb', line 16

def partials
  @partials ||= []
end

#propertiesObject

Ensure properties array is always initialized



11
12
13
# File 'lib/rails-openapi-gen/parsers/jbuilder/processors/base_processor.rb', line 11

def properties
  @properties ||= []
end