Module: Xmlenc::Builder::Base::XmlMapperClassMethods

Defined in:
lib/xmlenc/builder/base.rb

Instance Method Summary collapse

Instance Method Details

#parse(xml, options = {}) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/xmlenc/builder/base.rb', line 33

def parse(xml, options = {})
  raise Xmlenc::UnparseableMessage("Unable to parse nil document") if xml.nil?

  object = super
  if object.is_a?(Array)
    object.map { |x| x.from_xml = true }
  elsif object
    object.from_xml = true
  end
  object
rescue Nokogiri::XML::SyntaxError => e
  raise Xmlenc::UnparseableMessage.new(e.message)
rescue NoMethodError => e
  raise Xmlenc::UnparseableMessage.new(e.message)
end