Module: Saml::Base::XmlMapperClassMethods

Defined in:
lib/saml/base.rb

Instance Method Summary collapse

Instance Method Details

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



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/saml/base.rb', line 44

def parse(xml, options = {})
  if xml.is_a?(String)
    ActiveSupport::XmlMini_REXML.parse(xml)
  end

  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, REXML::ParseException => e
  raise Saml::Errors::UnparseableMessage.new(e.message)
rescue TypeError => e
  raise Saml::Errors::UnparseableMessage.new(e.message)
rescue NoMethodError => e
  raise Saml::Errors::UnparseableMessage.new(e.message)
end