Class: MarkupFuel::Library::Deserialize::Xml
- Inherits:
-
Burner::JobWithRegister
- Object
- Burner::JobWithRegister
- MarkupFuel::Library::Deserialize::Xml
- Defined in:
- lib/markup_fuel/library/deserialize/xml.rb
Overview
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.
Constant Summary collapse
- FORCE_ARRAY_KEY =
'ForceArray'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(force_array: false, name: '', register: Burner::DEFAULT_REGISTER) ⇒ Xml
constructor
A new instance of Xml.
- #perform(_output, payload) ⇒ Object
Constructor Details
#initialize(force_array: false, name: '', register: Burner::DEFAULT_REGISTER) ⇒ Xml
Returns a new instance of Xml.
25 26 27 28 29 30 31 32 33 34 35 |
# 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) = (force_array) freeze end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/markup_fuel/library/deserialize/xml.rb', line 23 def end |
Instance Method Details
#perform(_output, payload) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# 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], ) end |