Class: VORuby::VOResource::Mapping::FullObjectNode
- Inherits:
-
XML::Mapping::SubObjectBaseNode
- Object
- XML::Mapping::SubObjectBaseNode
- VORuby::VOResource::Mapping::FullObjectNode
- Defined in:
- lib/voruby/resources/nodes.rb
Overview
This is a copy of ObjectNode, but using REXML’s full XPath implementation (i.e. not pre-compiling expressions). It’s potentially slower but necessary for some schema.
Instance Method Summary collapse
-
#extract_attr_value(xml) ⇒ Object
:nodoc:.
-
#initialize_impl(path) ⇒ Object
Initializer.
-
#set_attr_value(xml, value) ⇒ Object
:nodoc:.
Instance Method Details
#extract_attr_value(xml) ⇒ Object
:nodoc:
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/voruby/resources/nodes.rb', line 104 def extract_attr_value(xml) # :nodoc: paths = [] @path_str.split(/\s*\|\s*/).each{ |path| paths << path xml.prefixes.each{ |prefix| paths << "#{prefix}:#{path}" } } xpath = paths.join('|') result = default_when_xpath_err{REXML::XPath.first(xml, xpath)} result ? @options[:unmarshaller].call(result): nil end |
#initialize_impl(path) ⇒ Object
Initializer. path (a string denoting an XPath expression) is the location of the subtree.
99 100 101 102 |
# File 'lib/voruby/resources/nodes.rb', line 99 def initialize_impl(path) super @path_str = path end |
#set_attr_value(xml, value) ⇒ Object
:nodoc:
118 119 120 |
# File 'lib/voruby/resources/nodes.rb', line 118 def set_attr_value(xml, value) # :nodoc: @options[:marshaller].call(@path.first(xml,:ensure_created=>true), value) end |