Class: LitleOnline::OptionalChoiceNode

Inherits:
XML::Mapping::ChoiceNode
  • Object
show all
Defined in:
lib/XMLFields.rb

Instance Method Summary collapse

Instance Method Details

#obj_to_xml(obj, xml) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/XMLFields.rb', line 31

def obj_to_xml(obj,xml)
  count = 0
  @choices.each do |path,node|
    if node.is_present_in? obj
      count = count + 1
    end
  end
  if(count > 1)
    raise RuntimeError, "Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!"
  end
  @choices.each do |path,node|
    if node.is_present_in? obj
      node.obj_to_xml(obj,xml)
      path.first(xml, :ensure_created=>true)
      return true
    end
  end
end