Class: Tilia::DavAcl::Xml::Request::PrincipalPropertySearchReport
- Includes:
- Xml::XmlDeserializable
- Defined in:
- lib/tilia/dav_acl/xml/request/principal_property_search_report.rb
Overview
PrincipalSearchPropertySetReport request parser.
This class parses the DAV:principal-property-search REPORT, as defined in:
Instance Attribute Summary collapse
-
#apply_to_principal_collection_set ⇒ Object
By default the property search will be conducted on the url of the http request.
-
#properties ⇒ Object
The requested properties.
-
#search_properties ⇒ Object
searchProperties.
-
#test ⇒ Object
Search for principals matching ANY of the properties (OR) or a ALL of the properties (AND).
Class Method Summary collapse
-
.xml_deserialize(reader) ⇒ Object
The deserialize method is called during xml parsing.
Instance Method Summary collapse
-
#initialize ⇒ PrincipalPropertySearchReport
constructor
TODO: document.
Constructor Details
#initialize ⇒ PrincipalPropertySearchReport
TODO: document
103 104 105 106 |
# File 'lib/tilia/dav_acl/xml/request/principal_property_search_report.rb', line 103 def initialize @search_properties = {} @apply_to_principal_collection_set = false end |
Instance Attribute Details
#apply_to_principal_collection_set ⇒ Object
By default the property search will be conducted on the url of the http request. If this is set to true, it will be applied to the principal collection set instead.
33 34 35 |
# File 'lib/tilia/dav_acl/xml/request/principal_property_search_report.rb', line 33 def apply_to_principal_collection_set @apply_to_principal_collection_set end |
#properties ⇒ Object
The requested properties.
21 22 23 |
# File 'lib/tilia/dav_acl/xml/request/principal_property_search_report.rb', line 21 def properties @properties end |
#search_properties ⇒ Object
searchProperties
26 27 28 |
# File 'lib/tilia/dav_acl/xml/request/principal_property_search_report.rb', line 26 def search_properties @search_properties end |
#test ⇒ Object
Search for principals matching ANY of the properties (OR) or a ALL of the properties (AND).
This property is either “anyof” or “allof”.
41 42 43 |
# File 'lib/tilia/dav_acl/xml/request/principal_property_search_report.rb', line 41 def test @test end |
Class Method Details
.xml_deserialize(reader) ⇒ Object
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.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/tilia/dav_acl/xml/request/principal_property_search_report.rb', line 62 def self.xml_deserialize(reader) instance = new found_search_prop = false instance.test = 'allof' instance.test = 'anyof' if reader.get_attribute('test') == 'anyof' elem_map = { '{DAV:}property-search' => Tilia::Xml::Element::KeyValue, '{DAV:}prop' => Tilia::Xml::Element::KeyValue } reader.parse_inner_tree(elem_map).each do |elem| case elem['name'] when '{DAV:}prop' instance.properties = elem['value'].keys when '{DAV:}property-search' found_search_prop = true # This property has two sub-elements: # {DAV:}prop - The property to be searched on. This may # also be more than one # {DAV:}match - The value to match with if !elem['value'].key?('{DAV:}prop') || !elem['value'].key?('{DAV:}match') fail Dav::Exception::BadRequest, 'The {DAV:}property-search element must contain one {DAV:}match and one {DAV:}prop element' end elem['value']['{DAV:}prop'].each do |prop_name, _discard| instance.search_properties[prop_name] = elem['value']['{DAV:}match'] end when '{DAV:}apply-to-principal-collection-set' instance.apply_to_principal_collection_set = true end end unless found_search_prop fail Dav::Exception::BadRequest, 'The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element' end instance end |