Class: Tilia::CalDav::Xml::Request::Share
- Includes:
- Xml::XmlDeserializable
- Defined in:
- lib/tilia/cal_dav/xml/request/share.rb
Overview
Share POST request parser
This class parses the share POST request, as defined in:
Instance Attribute Summary collapse
-
#remove ⇒ Object
List of people removed from the share list.
-
#set ⇒ Object
The list of new people added or updated.
Class Method Summary collapse
-
.xml_deserialize(reader) ⇒ Object
The deserialize method is called during xml parsing.
Instance Method Summary collapse
-
#initialize(set, remove) ⇒ Share
constructor
Constructor.
Constructor Details
#initialize(set, remove) ⇒ Share
Constructor
35 36 37 38 |
# File 'lib/tilia/cal_dav/xml/request/share.rb', line 35 def initialize(set, remove) @set = set @remove = remove end |
Instance Attribute Details
#remove ⇒ Object
List of people removed from the share list.
The list is a flat list of email addresses (including mailto:).
29 30 31 |
# File 'lib/tilia/cal_dav/xml/request/share.rb', line 29 def remove @remove end |
#set ⇒ Object
The list of new people added or updated.
Every element has the following keys:
-
href - An email address
-
commonName - Some name
-
summary - An optional description of the share
-
readOnly - true or false
22 23 24 |
# File 'lib/tilia/cal_dav/xml/request/share.rb', line 22 def set @set 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.
59 60 61 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 |
# File 'lib/tilia/cal_dav/xml/request/share.rb', line 59 def self.xml_deserialize(reader) elems = reader.parse_inner_tree( "{#{Plugin::NS_CALENDARSERVER}}set" => Tilia::Xml::Element::KeyValue, "{#{Plugin::NS_CALENDARSERVER}}remove" => Tilia::Xml::Element::KeyValue ) set = [] remove = [] elems.each do |elem| case elem['name'] when "{#{Plugin::NS_CALENDARSERVER}}set" sharee = elem['value'] sum_elem = "{#{Plugin::NS_CALENDARSERVER}}summary" common_name = "{#{Plugin::NS_CALENDARSERVER}}common-name" set << { 'href' => sharee['{DAV:}href'], 'commonName' => sharee[common_name], 'summary' => sharee[sum_elem], 'readOnly' => !sharee.key?("{#{Plugin::NS_CALENDARSERVER}}read-write") } when "{#{Plugin::NS_CALENDARSERVER}}remove" remove << elem['value']['{DAV:}href'] end end new(set, remove) end |