lib/roxml/xml/references.rb in roxml-3.2.0 vs lib/roxml/xml/references.rb in roxml-3.2.1
- old
+ new
@@ -30,15 +30,16 @@
def xpath_name
namespacify(name)
end
def value_in(xml)
- xml = XML::Node.from(xml)
- value = fetch_value(xml)
+ value = fetch_value(XML::Node.from(xml))
value = default if value.nil?
- freeze(apply_blocks(value))
+ value = apply_blocks(value)
+ value = freeze(value) if value && opts.frozen?
+ value
end
private
def conventionize(what)
convention ||= @instance.class.respond_to?(:roxml_naming_convention) && @instance.class.roxml_naming_convention
@@ -65,16 +66,12 @@
raise ex, "#{accessor}: #{ex.message}"
end
end
def freeze(val)
- if opts.frozen?
- val.each(&:freeze) if val.is_a?(Enumerable)
- val.freeze
- else
- val
- end
+ val.each(&:freeze) if val.is_a?(Enumerable)
+ val.freeze
end
def xpath
opts.wrapper ? "#{namespacify(opts.wrapper)}/#{xpath_name}" : xpath_name.to_s
end
@@ -267,15 +264,11 @@
end
to_hash(vals) if vals
end
def freeze(vals)
- if opts.frozen?
- vals.each_pair{|k, v| k.freeze; v.freeze }
- vals.freeze
- else
- vals
- end
+ vals.each_pair{|k, v| k.freeze; v.freeze }
+ vals.freeze
end
def to_hash(array)
hash = array.inject({}) do |result, (k, v)|
result[k] ||= []