Class: MarkupFuel::Library::Serialize::Xml
- Inherits:
-
Burner::JobWithRegister
- Object
- Burner::JobWithRegister
- MarkupFuel::Library::Serialize::Xml
- Defined in:
- lib/markup_fuel/library/serialize/xml.rb
Overview
This job works on a single register, reads its value, and 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_out API.
Expected Payload input: Ruby object modeling. Payload output: XML representation of the Ruby object modeling as a string.
Constant Summary collapse
- NO_ATTR_KEY =
'NoAttr'- ROOT_NAME_KEY =
'RootName'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(name: '', no_attributes: true, register: Burner::DEFAULT_REGISTER, root_name: nil) ⇒ Xml
constructor
A new instance of Xml.
- #make_options(no_attributes, root_name) ⇒ Object
- #perform(_output, payload) ⇒ Object
Constructor Details
#initialize(name: '', no_attributes: true, register: Burner::DEFAULT_REGISTER, root_name: nil) ⇒ Xml
Returns a new instance of Xml.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/markup_fuel/library/serialize/xml.rb', line 26 def initialize( name: '', no_attributes: true, register: Burner::DEFAULT_REGISTER, root_name: nil ) super(name: name, register: register) = (no_attributes, root_name) freeze end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/markup_fuel/library/serialize/xml.rb', line 24 def end |
Instance Method Details
#make_options(no_attributes, root_name) ⇒ Object
43 44 45 46 47 |
# File 'lib/markup_fuel/library/serialize/xml.rb', line 43 def (no_attributes, root_name) { NO_ATTR_KEY => no_attributes }.tap do |opts| opts[ROOT_NAME_KEY] = root_name unless root_name.to_s.empty? end end |
#perform(_output, payload) ⇒ Object
39 40 41 |
# File 'lib/markup_fuel/library/serialize/xml.rb', line 39 def perform(_output, payload) payload[register] = XmlSimple.xml_out(payload[register] || {}, ) end |