Class: Stash::Wrapper::DescriptiveNode
- Inherits:
-
XML::Mapping::SingleAttributeNode
- Object
- XML::Mapping::SingleAttributeNode
- Stash::Wrapper::DescriptiveNode
- Defined in:
- lib/stash/wrapper/descriptive_node.rb
Overview
Node class for <st:stash_descriptive> elements.
Instance Method Summary collapse
-
#extract_attr_value(xml) ⇒ Array<REXML::Element>
Extracts the children of this element as an array.
-
#initialize(*args) ⇒ DescriptiveNode
constructor
See
XML::Mapping::SingleAttributeNode#initialize. -
#set_attr_value(xml, value) ⇒ Object
Sets the array of elements representetd by this node as the children of the corresponding
<st:stash_descriptive>element.
Constructor Details
#initialize(*args) ⇒ DescriptiveNode
See XML::Mapping::SingleAttributeNode#initialize
10 11 12 13 14 |
# File 'lib/stash/wrapper/descriptive_node.rb', line 10 def initialize(*args) path, *myargs = super(*args) @path = ::XML::XXPath.new(path) myargs # rubocop:disable Lint/Void end |
Instance Method Details
#extract_attr_value(xml) ⇒ Array<REXML::Element>
Extracts the children of this element as an array.
19 20 21 |
# File 'lib/stash/wrapper/descriptive_node.rb', line 19 def extract_attr_value(xml) default_when_xpath_err { @path.first(xml).elements.to_a } end |
#set_attr_value(xml, value) ⇒ Object
Sets the array of elements representetd by this node
as the children of the corresponding <st:stash_descriptive>
element.
28 29 30 31 32 33 |
# File 'lib/stash/wrapper/descriptive_node.rb', line 28 def set_attr_value(xml, value) parent = @path.first(xml, ensure_created: true) value.each do |child| parent.elements.add(child) end end |