Module ActiveSupport::XmlMini_Nokogiri::Conversions::Node
In: vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb

Methods

Constants

CONTENT_ROOT = '__content__'

Public Instance methods

[Source]

    # File vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb, line 58
58:         def attributes_as_hash
59:           Hash[*(attribute_nodes.map { |node|
60:             [node.node_name, node.value]
61:           }.flatten)]
62:         end

Convert XML document to hash

hash:Hash to merge the converted element into.

[Source]

    # File vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb, line 35
35:         def to_hash(hash = {})
36:           attributes = attributes_as_hash
37:           if hash[name]
38:             hash[name] = [hash[name]].flatten
39:             hash[name] << attributes
40:           else
41:             hash[name] ||= attributes
42:           end
43: 
44:           children.each { |child|
45:             next if child.blank? && 'file' != self['type']
46: 
47:             if child.text? || child.cdata?
48:               (attributes[CONTENT_ROOT] ||= '') << child.content
49:               next
50:             end
51: 
52:             child.to_hash attributes
53:           }
54: 
55:           hash
56:         end

[Validate]