Class: ROXML::XMLObjectRef

Inherits:
XMLTextRef show all
Defined in:
lib/roxml/xml/references.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from XMLRef

#opts

Instance Method Summary collapse

Methods inherited from XMLRef

#blocks, #initialize, #name, #to_xml, #value_in, #xpath_name

Constructor Details

This class inherits a constructor from ROXML::XMLRef

Instance Method Details

#update_xml(xml, value) ⇒ Object

Updates the composed XML object in the given XML block to the value provided.



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/roxml/xml/references.rb', line 305

def update_xml(xml, value)
  wrap(xml).tap do |xml|
    params = {:name => name, :namespace => opts.namespace}
    if array?
      value.each do |v|
        XML.add_child(xml, v.to_xml(params))
      end
    elsif value.is_a?(ROXML)
      XML.add_child(xml, value.to_xml(params))
    else
      XML.add_node(xml, name).tap do |node|
        XML.set_content(node, value.to_xml)
      end
    end
  end
end