Module: Ldbws::ResponseTypes::ParsingFunctions::ClassFunctions
- Defined in:
- lib/ldbws/response_types/parsing_functions.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#from_xml(xml_node) ⇒ Object
Creates an object from an XML node.
Instance Method Details
#from_xml(xml_node) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ldbws/response_types/parsing_functions.rb', line 36 def from_xml(xml_node) raise "Oh no" if properties.empty? props = properties.dup.map do |key, defn| # look for the node, and return the default if we can’t find it found = xml_node.xpath("./#{defn[:selector]}") next [key, defn[:default]] unless found.any? [ key, if defn[:collection] found.map { |node| parse_property(node, defn) }.compact else parse_property(found.first, defn) end, ] end.to_h new(props) end |