Sha256: 5bcb5c312fe98ba41e23805a3c15b933b6fc44832c1e47f720ec322bfed3fb10
Contents?: true
Size: 824 Bytes
Versions: 6
Compression:
Stored size: 824 Bytes
Contents
require 'ostruct' module RackWebDAV # Simple wrapper for formatted elements class DAVElement < OpenStruct def [](key) self.send(key) end end module Utils def to_element_hash(element) ns = element.namespace DAVElement.new( :namespace => ns, :name => element.name, :ns_href => (ns.href if ns), :children => element.children.collect{|e| to_element_hash(e) if e.element? }.compact, :attributes => attributes_hash(element) ) end def to_element_key(element) ns = element.namespace "#{ns.href if ns}!!#{element.name}" end private def attributes_hash(node) node.attributes.inject({}) do |ret, (key,attr)| ret[attr.name] = attr.value ret end end end end
Version data entries
6 entries across 6 versions & 1 rubygems