Method: Jamf::XMLWorkaround.remove_size_sub_elem

Defined in:
lib/jamf/api/classic/xml_workaround.rb

.remove_size_sub_elem(elem) ⇒ Object

remove the ‘size’ sub element from a given element as long as:

  • a sub element named ‘size’ exists

  • there’s only one sub element named ‘size’

  • it doesn’t have sub elements itself

  • and it contains an integer value

Such elements are extraneous for the most part, and are not consistently located - sometimes they are in the Array-ish elements they reference, sometimes they are alongside them. In any case they confuse the logic when deciding if an element with sub-elements should become an Array or a Hash.



173
174
175
176
177
178
179
180
181
182
# File 'lib/jamf/api/classic/xml_workaround.rb', line 173

def self.remove_size_sub_elem(elem)
  size_elems = elem.elements.to_a.select { |subel| subel.name == SIZE_ELEM_NAME }
  size_elem = size_elems.first
  return unless size_elem
  return unless size_elems.count == 1
  return if size_elem.has_elements?
  return unless size_elem.text.jss_integer?

  elem.delete_element size_elem
end