Class: Zimbra::Appointment::Attendee
- Inherits:
-
Object
- Object
- Zimbra::Appointment::Attendee
- Defined in:
- lib/zimbra/appointment/attendee.rb
Constant Summary collapse
- ATTRS =
[ :email_address, :friendly_name, :rsvp, :role, :participation_status ]
Class Method Summary collapse
- .new_from_zimbra_attributes(zimbra_attributes) ⇒ Object
- .parse_zimbra_attributes(zimbra_attributes) ⇒ Object
Instance Method Summary collapse
-
#attributes=(args = {}) ⇒ Object
take attributes by the xml name or our more descriptive name.
- #create_xml(document) ⇒ Object
-
#initialize(args = {}) ⇒ Attendee
constructor
A new instance of Attendee.
- #participation_status=(val) ⇒ Object
- #participation_status_to_zimbra ⇒ Object
- #to_hash(options = {}) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Attendee
Returns a new instance of Attendee.
28 29 30 |
# File 'lib/zimbra/appointment/attendee.rb', line 28 def initialize(args = {}) self.attributes = args end |
Class Method Details
.new_from_zimbra_attributes(zimbra_attributes) ⇒ Object
11 12 13 |
# File 'lib/zimbra/appointment/attendee.rb', line 11 def new_from_zimbra_attributes(zimbra_attributes) new(parse_zimbra_attributes(zimbra_attributes)) end |
.parse_zimbra_attributes(zimbra_attributes) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zimbra/appointment/attendee.rb', line 15 def parse_zimbra_attributes(zimbra_attributes) zimbra_attributes = Zimbra::Hash.symbolize_keys(zimbra_attributes.dup, true) { :email_address => zimbra_attributes[:a], :friendly_name => zimbra_attributes[:d], :rsvp => zimbra_attributes[:rsvp], :role => zimbra_attributes[:role], :participation_status => zimbra_attributes[:ptst] } end |
Instance Method Details
#attributes=(args = {}) ⇒ Object
take attributes by the xml name or our more descriptive name
33 34 35 36 37 38 39 40 41 |
# File 'lib/zimbra/appointment/attendee.rb', line 33 def attributes=(args = {}) ATTRS.each do |attr_name| if args.has_key?(attr_name) self.send(:"#{attr_name}=", args[attr_name]) elsif args.has_key?(attr_name.to_s) self.send(:"#{attr_name}=", args[attr_name.to_s]) end end end |
#create_xml(document) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/zimbra/appointment/attendee.rb', line 64 def create_xml(document) document.add "at" do |at_element| at_element.set_attr "a", email_address at_element.set_attr "d", friendly_name at_element.set_attr "ptst", participation_status_to_zimbra end end |
#participation_status=(val) ⇒ Object
43 44 45 |
# File 'lib/zimbra/appointment/attendee.rb', line 43 def participation_status=(val) @participation_status = parse_participation_status(val) end |
#participation_status_to_zimbra ⇒ Object
47 48 49 |
# File 'lib/zimbra/appointment/attendee.rb', line 47 def participation_status_to_zimbra possible_participation_status_values.find { |k, v| v == participation_status }.first rescue participiation_status end |
#to_hash(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/zimbra/appointment/attendee.rb', line 51 def to_hash( = {}) hash = { :email_address => email_address, :friendly_name => friendly_name, :rsvp => rsvp, :role => role, :participation_status => participation_status } hash.reject! { |key, value| [:except].include?(key.to_sym) || [:except].include?(key.to_s) } if [:except] hash.reject! { |key, value| ![:only].include?(key.to_sym) && ![:only].include?(key.to_s) } if [:only] hash end |