Class: Tilia::DavAcl::Xml::Property::SupportedPrivilegeSet

Inherits:
Object
  • Object
show all
Includes:
Tilia::Dav::Browser::HtmlOutput, Xml::XmlSerializable
Defined in:
lib/tilia/dav_acl/xml/property/supported_privilege_set.rb

Overview

SupportedPrivilegeSet property

This property encodes the DAV:supported-privilege-set property, as defined in rfc3744. Please consult the rfc for details about it’s structure.

This class expects a structure like the one given from Tilia::DavAcl::Plugin::getSupportedPrivilegeSet as the argument in its constructor.

Author:

Instance Method Summary collapse

Constructor Details

#initialize(privileges) ⇒ SupportedPrivilegeSet

Constructor

Parameters:

  • array

    privileges



33
34
35
# File 'lib/tilia/dav_acl/xml/property/supported_privilege_set.rb', line 33

def initialize(privileges)
  @privileges = privileges
end

Instance Method Details

#to_html(html) ⇒ Object

Generate html representation for this value.

The html output is 100% trusted, and no effort is being made to sanitize it. It’s up to the implementor to sanitize user provided values.

The output must be in UTF-8.

The baseUri parameter is a url to the root of the application, and can be used to construct local links.

Parameters:

  • HtmlOutputHelper

    html

Returns:

  • string



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/tilia/dav_acl/xml/property/supported_privilege_set.rb', line 77

def to_html(html)
  traverse = lambda do |priv|
    output = '<li>'
    output << html.xml_name(priv['privilege'])
    output << ' <i>(abstract)</i>' unless priv['abstract'].blank?
    output << " #{html.h(priv['description'])}" if priv.key?('description')

    if priv.key?('aggregates')
      output << "\n<ul>\n"
      priv['aggregates'].each do |sub_priv|
        output << traverse.call(sub_priv)
      end
      output << '</ul>'
    end
    output << "</li>\n"

    output
  end

  output = "<ul class=\"tree\">"
  output << traverse.call(@privileges)
  output << "</ul>\n"

  output
end

#valueObject

Returns the privilege value.

Returns:

  • array



40
41
42
# File 'lib/tilia/dav_acl/xml/property/supported_privilege_set.rb', line 40

def value
  @privileges
end

#xml_serialize(writer) ⇒ Object

The xmlSerialize metod is called during xml writing.

Use the writer argument to write its own xml serialization.

An important note: do not create a parent element. Any element implementing XmlSerializble should only ever write what’s considered its ‘inner xml’.

The parent of the current element is responsible for writing a containing element.

This allows serializers to be re-used for different element names.

If you are opening new elements, you must also close them again.

Parameters:

  • Writer

    writer

Returns:

  • void



61
62
63
# File 'lib/tilia/dav_acl/xml/property/supported_privilege_set.rb', line 61

def xml_serialize(writer)
  serialize_priv(writer, @privileges)
end