instance method hash_to_array

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.2.3 Private

Signature

hash_to_array(parent, hashref)

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.

Parameters

parent req
hashref req
Source
# File activesupport/lib/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

Defined in activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb line 874 · View on GitHub · Improve this page · Find usages on GitHub

Defined in XmlSimple

Type at least 2 characters to search.

↑↓ navigate · open · esc close