class MarkupFuel::Library::Deserialize::Xml

This job works on a single register, reads its value, and de-serializes it using the XmlSimple gem. There is some nice documentation that ships with the gem located here: github.com/maik/xml-simple/tree/master/docs. More or less, this is just a Burner::Job wrapper around the XmlSimple#xml_in API.

Expected Payload input: string of XML. Payload output: Ruby object representation of the XML.

Constants

FORCE_ARRAY_KEY

Attributes

options[R]

Public Class Methods

new( force_array: false, name: '', register: Burner::DEFAULT_REGISTER ) click to toggle source
Calls superclass method
# File lib/markup_fuel/library/deserialize/xml.rb, line 25
def initialize(
  force_array: false,
  name: '',
  register: Burner::DEFAULT_REGISTER
)
  super(name: name, register: register)

  @options = make_options(force_array)

  freeze
end

Public Instance Methods

perform(_output, payload) click to toggle source
# File lib/markup_fuel/library/deserialize/xml.rb, line 37
def perform(_output, payload)
  value = payload[register]

  if value.to_s.empty?
    payload[register] = nil
    return
  end

  payload[register] = XmlSimple.xml_in(payload[register], options)
end

Private Instance Methods

make_options(force_array) click to toggle source
# File lib/markup_fuel/library/deserialize/xml.rb, line 50
def make_options(force_array)
  { FORCE_ARRAY_KEY => force_array }
end