Method: CoreLibrary::XmlHelper.from_element

Defined in:
lib/apimatic-core/utilities/xml_helper.rb

.from_element(parent, name, clazz, datetime_format: nil) ⇒ Object

Converts element to a specific class.

Parameters:

  • parent (String)

    Parent XML.

  • name (String)

    Attribute name.

  • clazz (Class)

    Attribute class.

  • datetime_format (CoreLibrary::DateTimeFormat) (defaults to: nil)

    Datetime format to use for conversion..



188
189
190
191
192
193
194
# File 'lib/apimatic-core/utilities/xml_helper.rb', line 188

def from_element(parent, name, clazz, datetime_format: nil)
  element = parent.at_xpath(name)
  return nil if element.nil?
  return clazz.from_element element if clazz.respond_to? :from_element

  convert(element.text, clazz, datetime_format)
end