Class: VORuby::VOResource::Mapping::FullArrayNode

Inherits:
XML::Mapping::SubObjectBaseNode
  • Object
show all
Defined in:
lib/voruby/resources/nodes.rb

Instance Method Summary collapse

Instance Method Details

#do_initialize(base_path, per_arrelement_path) ⇒ Object

“Real” initializer.



139
140
141
142
# File 'lib/voruby/resources/nodes.rb', line 139

def do_initialize(base_path, per_arrelement_path)
  @base_path = base_path
  @per_arrelement_path = per_arrelement_path
end

#extract_attr_value(xml) ⇒ Object

:nodoc:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/voruby/resources/nodes.rb', line 144

def extract_attr_value(xml) # :nodoc:
  paths = []
  @per_arrelement_path.split(/\s*\|\s*/).each{ |path|
    paths << path
    xml.prefixes.each{ |prefix|
      paths << "#{prefix}:#{path}"
    }
  }
  xpath = @base_path + '(' + paths.join('|') + ')'
  
  result = []
  default_when_xpath_err{REXML::XPath.match(xml, xpath)}.each do |elt|
    result << @options[:unmarshaller].call(elt)
  end
  
  result
end

#initialize_impl(path, path2 = nil) ⇒ Object

Initializer, delegates to do_initialize. Called with keyword arguments and either 1 or 2 paths; the hindmost path argument passed is delegated to per_arrelement_path; the preceding path argument (if present, “” by default) is delegated to base_path.



129
130
131
132
133
134
135
136
# File 'lib/voruby/resources/nodes.rb', line 129

def initialize_impl(path,path2=nil)
  super
 if path2
   do_initialize(path,path2)
 else
   do_initialize("",path)
 end
end

#set_attr_value(xml, value) ⇒ Object

:nodoc:



162
163
164
165
166
167
# File 'lib/voruby/resources/nodes.rb', line 162

def set_attr_value(xml, value) # :nodoc:
 base_elt = @base_path.first(xml,:ensure_created=>true)
 value.each do |arr_elt|
      @options[:marshaller].call(@per_arrelement_path.create_new(base_elt), arr_elt)
   end
end