Module: XML::Mapping::ClassMethods
- Defined in:
- lib/xml/mapping_extensions.rb
Instance Method Summary collapse
-
#parse_xml(xml) ⇒ Object
Create a new instance of this class from the XML contained in
xml, which can be a string, REXML document, or REXML element.
Instance Method Details
#parse_xml(xml) ⇒ Object
Create a new instance of this class from the XML contained in
xml, which can be a string, REXML document, or REXML element
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xml/mapping_extensions.rb', line 32 def parse_xml(xml) element = case xml when REXML::Document xml.root when REXML::Element xml else fail ArgumentError, "Unexpected argument type; expected XML document, String, or IO source, was #{xml.class}" unless can_parse(xml) REXML::Document.new(xml).root end load_from_xml(element) end |