Class: ROXML::XMLHashRef

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, #name, #to_xml, #value_in, #xpath_name

Constructor Details

#initialize(opts, inst) ⇒ XMLHashRef

Returns a new instance of XMLHashRef.



223
224
225
226
227
# File 'lib/roxml/xml/references.rb', line 223

def initialize(opts, inst)
  super(opts, inst)
  @key = opts.hash.key.to_ref(inst)
  @value = opts.hash.value.to_ref(inst)
end

Instance Method Details

#several?Boolean

Returns:

  • (Boolean)


229
230
231
# File 'lib/roxml/xml/references.rb', line 229

def several?
  true
end

#update_xml(xml, value) ⇒ Object

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



235
236
237
238
239
240
241
242
243
# File 'lib/roxml/xml/references.rb', line 235

def update_xml(xml, value)
  wrap(xml).tap do |xml|
    value.each_pair do |k, v|
      node = xml.add_child(XML::Node.create(hash.wrapper))
      @key.update_xml(node, k)
      @value.update_xml(node, v)
    end
  end
end