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.



245
246
247
248
249
# File 'lib/roxml/xml/references.rb', line 245

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)


251
252
253
# File 'lib/roxml/xml/references.rb', line 251

def several?
  true
end

#update_xml(xml, value) ⇒ Object

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



257
258
259
260
261
262
263
264
265
# File 'lib/roxml/xml/references.rb', line 257

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