19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/loader.rb', line 19
def self.get_mo_from_xml(parent_mo, element)
class_name = element.name
unless ACIrb::CLASSMAP.include?(class_name)
fail 'Could not find class "%s" defined in "%s"' % \
[class_name, element.to_s]
end
mo = ACIrb.const_get(ACIrb::CLASSMAP[class_name])
create_attr = {}
element.attributes.each do |k, v|
create_attr[k.to_s] = v.to_s
end
create_attr[:mark_dirty] = false
mo = mo.new(parent_mo, create_attr)
element.elements.each do |e|
mo.add_child(get_mo_from_xml(mo, e))
end
mo
end
|