Sha256: b02a8e37f0769c0da79e9ebd8b99d81fa85d462a6e5969f0d53ba48c24bc4137
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 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, *myargs = super(*args) @path = ::XML::XXPath.new(path) myargs # rubocop:disable Lint/Void 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stash-wrapper-0.1.12 | lib/stash/wrapper/descriptive_node.rb |