Attempts to unfold a hash of hashes into an array of hashes. Returns a reference to th array on success or the original hash, if unfolding is not possible.
parent::
| hashref: | Reference to the hash to be unfolded. |
Source Code
# File active_support/vendor/xml-simple-1.0.11/xmlsimple.rb, line 874 def hash_to_array(parent, hashref) arrayref = [] hashref.each { |key, value| return hashref unless value.instance_of?(Hash) if @options['keyattr'].instance_of?(Hash) return hashref unless @options['keyattr'].has_key?(parent) arrayref << { @options['keyattr'][parent][0] => key }.update(value) else arrayref << { @options['keyattr'][0] => key }.update(value) end } arrayref end
<code/>and<pre/>for code samples.