lib/roxml/xml/references.rb in roxml-3.2.2 vs lib/roxml/xml/references.rb in roxml-3.3.0
- old
+ new
@@ -58,15 +58,13 @@
end
what
end
def apply_blocks(val)
- begin
- blocks.inject(val) {|val, block| block.call(val) }
- rescue Exception => ex
- raise ex, "#{accessor}: #{ex.message}"
- end
+ blocks.inject(val) {|val, block| block.call(val) }
+ rescue Exception => ex
+ raise ex, "#{accessor}: #{ex.message}"
end
def freeze(val)
val.each(&:freeze) if val.is_a?(Enumerable)
val.freeze
@@ -88,29 +86,28 @@
array?
end
def wrap(xml, opts = {:always_create => false})
wrap_with = @auto_vals ? auto_wrapper : wrapper
-
+
return xml if !wrap_with || xml.name == wrap_with
wraps = wrap_with.to_s.split('/')
- wraps.inject(xml) do |node,wrap|
- if !opts[:always_create] && (child = node.children.find {|c| c.name == wrap })
+ wraps.inject(xml) do |node,wrap|
+ if !opts[:always_create] && (child = node.children.find {|c| c.name == wrap })
child
else
- XML.add_node(node, wrap)
+ XML.add_node(node, wrap)
end
- end
-
+ end
end
def nodes_in(xml)
- @default_namespace = xml.default_namespace
- vals = xml.roxml_search(xpath, @instance.class.roxml_namespaces)
+ @default_namespace = XML.default_namespace(xml)
+ vals = XML.search(xml, xpath, @instance.class.roxml_namespaces)
if several? && vals.empty? && !wrapper && auto_xpath
- vals = xml.roxml_search(auto_xpath, @instance.class.roxml_namespaces)
+ vals = XML.search(xml, auto_xpath, @instance.class.roxml_namespaces)
@auto_vals = !vals.empty?
end
if vals.empty?
raise RequiredElementMissing, "#{name} from #{xml} for #{accessor}" if required?