82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/modl/parser/modl_method.rb', line 82
def self.(pair, global)
return unless pair.type == 'method'
mthd = MODLMethod.new
map = pair.map if pair.map
map = pair.valueItem&.value&.map if pair.valueItem&.value&.map
map.mapItems.each do |item|
next unless item&.pair&.type
case item&.pair&.type
when 'id'
mthd.id = item.pair.valueItem.value.primitive.string.string
when 'transform'
mthd.transform = item.pair.valueItem.value.primitive.string.string
when 'name'
mthd.name = item.pair.valueItem.value.primitive.string.string
else
raise InterpreterError, 'Invalid *method - only *id, *name, and *transform fields expected'
end
end
raise InterpreterError, 'Missing id for method' if mthd.id.nil?
raise InterpreterError, 'Missing name for method' if mthd.name.nil?
raise InterpreterError, 'Duplicate method name or id: ' + mthd.name if global.has_user_method?(mthd.name)
raise InterpreterError, 'Duplicate method name or id: ' + mthd.id if global.has_user_method?(mthd.id)
global.user_method_id(mthd.id, mthd)
global.user_method(mthd.name, mthd)
end
|