Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ali_mns.rb
Overview
Monkey patch hash to support xml array and xml object
Class Method Summary collapse
Class Method Details
.xml_array(content, *path) ⇒ Object
12 13 14 15 |
# File 'lib/ali_mns.rb', line 12 def self.xml_array content, *path o = xml_object(content, *path) return (o.is_a?(Array) ? o : [o]).reject{|n| n.empty?} end |
.xml_object(content, *path) ⇒ Object
17 18 19 20 |
# File 'lib/ali_mns.rb', line 17 def self.xml_object content, *path h = from_xml(content) path.reduce(h){|memo, node| memo = memo[node] || {}} end |