Module: DiasporaFederation::Salmon::XmlPayload Deprecated
- Defined in:
- lib/diaspora_federation/salmon/xml_payload.rb
Overview
Deprecated.
XmlPayload
provides methods to wrap a XML-serialized Entity inside a common XML structure that will become the payload for federation messages.
The wrapper looks like so:
<XML>
<post>
{data}
</post>
</XML>
(The post
element is there for historic reasons…)
Class Method Summary collapse
-
.unpack(xml) ⇒ Entity
Extracts the Entity XML from the wrapping XML structure, parses the entity XML and returns a new instance of the Entity that was packed inside the given payload.
Class Method Details
.unpack(xml) ⇒ Entity
Extracts the Entity XML from the wrapping XML structure, parses the entity XML and returns a new instance of the Entity that was packed inside the given payload.
26 27 28 29 30 31 32 |
# File 'lib/diaspora_federation/salmon/xml_payload.rb', line 26 def self.unpack(xml) raise ArgumentError, "only Nokogiri::XML::Element allowed" unless xml.instance_of?(Nokogiri::XML::Element) data = xml_wrapped?(xml) ? xml.at_xpath("post/*[1]") : xml Entity.entity_class(data.name).from_xml(data) end |