class Tilia::DavAcl::Xml::Request::ExpandPropertyReport

ExpandProperty request parser.

This class parses the {DAV:}expand-property REPORT, as defined in:

tools.ietf.org/html/rfc3253#section-3.8

@copyright Copyright (C) 2007-2015 fruux GmbH (fruux.com/). @author Evert Pot (evertpot.com/) @license sabre.io/license/ Modified BSD License

Attributes

properties[RW]

An array with requested properties.

The requested properties will be used as keys in this array. The value is normally null.

If the value is an array though, it means the property must be expanded. Within the array, the sub-properties, which themselves may be null or arrays.

@var array

Public Class Methods

traverse(elems) click to toggle source

This method is used by deserializeXml, to recursively parse the {DAV:}property elements.

@param array elems @return void

# File lib/tilia/dav_acl/xml/request/expand_property_report.rb, line 62
def self.traverse(elems)
  result = {}

  elems.each do |elem|
    next unless elem['name'] == '{DAV:}property'

    namespace = elem['attributes'].key?('namespace') ?
        elem['attributes']['namespace'] :
        'DAV:'

    prop_name = "{#{namespace}}#{elem['attributes']['name']}"

    value = nil
    value = traverse(elem['value']) if elem['value'].is_a?(Array)

    result[prop_name] = value
  end

  result
end
xml_deserialize(reader) click to toggle source

The deserialize method is called during xml parsing.

This method is called statictly, this is because in theory this method may be used as a type of constructor, or factory method.

Often you want to return an instance of the current class, but you are free to return other data as well.

You are responsible for advancing the reader to the next element. Not doing anything will result in a never-ending loop.

If you just want to skip parsing for this element altogether, you can just call reader.next

reader.parse_inner_tree will parse the entire sub-tree, and advance to the next element.

@param Reader reader @return mixed

# File lib/tilia/dav_acl/xml/request/expand_property_report.rb, line 48
def self.xml_deserialize(reader)
  elems = reader.parse_inner_tree

  obj = new
  obj.properties = traverse(elems)

  obj
end