Sha256: 8af984ad3f00550f5408b012623e8e3f91e105b2ff540a29178d31a88bcf7450
Contents?: true
Size: 1.14 KB
Versions: 12
Compression:
Stored size: 1.14 KB
Contents
require 'xml/mapping' module Stash module Wrapper # Node class for `<st:stash_descriptive>` elements. class DescriptiveNode < XML::Mapping::SingleAttributeNode # See `XML::Mapping::SingleAttributeNode#initialize` def initialize(*args) path, *args = super(*args) @path = ::XML::XXPath.new(path) args end # Extracts the children of this element as an array. # @param xml [REXML::Element] this `<st:stash_descriptive>` element # @return [Array<REXML::Element>] the child elements def extract_attr_value(xml) default_when_xpath_err { @path.first(xml).elements.to_a } end # Sets the array of elements representetd by this node # as the children of the corresponding `<st:stash_descriptive>` # element. # @param xml [REXML::Element] this element # @param value [Array<REXML::Element>] the child elements def set_attr_value(xml, value) parent = @path.first(xml, ensure_created: true) value.each do |child| parent.elements.add(child) end end end XML::Mapping.add_node_class DescriptiveNode end end
Version data entries
12 entries across 12 versions & 1 rubygems