Class: TaliaCore::ActiveSourceParts::Xml::SourceBuilder
- Inherits:
-
TaliaUtil::Xml::BaseBuilder
- Object
- TaliaUtil::Xml::BaseBuilder
- TaliaCore::ActiveSourceParts::Xml::SourceBuilder
- Defined in:
- lib/talia_core/active_source_parts/xml/source_builder.rb
Overview
Class to build source representations of ActiveSource objects. Talia uses a simple XML format to encode the Source Object. The format maps easily to a Hash as it is used for the new or write_attributes methods:
Also see the parent class, TaliaUtil::Xml::BaseBuilder, for more information
Class Method Summary collapse
-
.build_source(source) ⇒ Object
Builds the XML for a single source, and returns the result as a string.
Instance Method Summary collapse
-
#write_source(source) ⇒ Object
Build the XML for a single source.
Methods inherited from TaliaUtil::Xml::BaseBuilder
Class Method Details
.build_source(source) ⇒ Object
Builds the XML for a single source, and returns the result as a string
36 37 38 |
# File 'lib/talia_core/active_source_parts/xml/source_builder.rb', line 36 def self.build_source(source) make_xml_string { |build| build.write_source(source) } end |
Instance Method Details
#write_source(source) ⇒ Object
Build the XML for a single source.
41 42 43 44 45 46 |
# File 'lib/talia_core/active_source_parts/xml/source_builder.rb', line 41 def write_source(source) @builder.source do source.attributes.each { |attrib, value| write_attribute(attrib, value) } source.direct_predicates.each { |pred| write_attribute(pred, source[pred]) } end end |