Class: Kumi::Core::RubyParser::InputFieldProxy

Inherits:
Object
  • Object
show all
Extended by:
Sugar::ProxyRefinement
Includes:
Syntax
Defined in:
lib/kumi/core/ruby_parser/input_field_proxy.rb

Overview

Proxy for input field access that can handle arbitrary depth nesting Handles input.field.subfield.subsubfield… syntax by building up path arrays

Instance Method Summary collapse

Methods included from Sugar::ProxyRefinement

extended

Constructor Details

#initialize(path, context) ⇒ InputFieldProxy

Returns a new instance of InputFieldProxy.



14
15
16
17
# File 'lib/kumi/core/ruby_parser/input_field_proxy.rb', line 14

def initialize(path, context)
  @path = Array(path) # Ensure it's always an array
  @context = context
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



32
33
34
35
36
37
38
39
40
# File 'lib/kumi/core/ruby_parser/input_field_proxy.rb', line 32

def method_missing(method_name, *args, &block)
  if args.empty? && block.nil?
    # Extend the path: input.user.details -> InputFieldProxy([user, details])
    InputFieldProxy.new(@path + [method_name], @context)
  else
    # Operators are now handled by ProxyRefinement methods
    super
  end
end

Instance Method Details

#to_ast_nodeObject

Convert to appropriate AST node based on path length



20
21
22
23
24
25
26
27
28
# File 'lib/kumi/core/ruby_parser/input_field_proxy.rb', line 20

def to_ast_node
  if @path.length == 1
    # Single field: input.field -> InputReference
    Kumi::Syntax::InputReference.new(@path.first, loc: @context.current_location)
  else
    # Nested fields: input.field.subfield... -> InputElementReference
    Kumi::Syntax::InputElementReference.new(@path, loc: @context.current_location)
  end
end