Module: Cel::CollectionTypeFetch

Included in:
Cel
Defined in:
lib/cel/ast/types.rb

Instance Method Summary collapse

Instance Method Details

#[](*args) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/cel/ast/types.rb', line 105

def [](*args)
  col_type, elem_type = args

  return super unless COLTYPES.include?(col_type)

  return super if args.size > 2

  elem_type ||= :any

  type = case col_type
         when :list
           ListType.new([])
         when :map
           MapType.new({})
  end

  type.element_type = super(*elem_type)
  type
end