Class: Zimbra::Appointment::RecurException
- Inherits:
-
Object
- Object
- Zimbra::Appointment::RecurException
- Defined in:
- lib/zimbra/appointment/recur_exception.rb
Constant Summary collapse
- ATTRS =
[ :recurrence_id, :timezone, :range_type ]
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 = {}) ⇒ RecurException
constructor
A new instance of RecurException.
- #range_type=(val) ⇒ Object
- #range_type_to_zimbra ⇒ Object
- #to_hash(options = {}) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ RecurException
Returns a new instance of RecurException.
33 34 35 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 33 def initialize(args = {}) self.attributes = args end |
Class Method Details
.new_from_zimbra_attributes(zimbra_attributes) ⇒ Object
5 6 7 8 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 5 def new_from_zimbra_attributes(zimbra_attributes) return nil unless zimbra_attributes new(parse_zimbra_attributes(zimbra_attributes)) end |
.parse_zimbra_attributes(zimbra_attributes) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 10 def parse_zimbra_attributes(zimbra_attributes) zimbra_attributes = Zimbra::Hash.symbolize_keys(zimbra_attributes.dup, true) { :recurrence_id => zimbra_attributes[:d], :timezone => zimbra_attributes[:tz], :range_type => zimbra_attributes[:rangeType] } end |
Instance Method Details
#attributes=(args = {}) ⇒ Object
take attributes by the xml name or our more descriptive name
38 39 40 41 42 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 38 def attributes=(args = {}) ATTRS.each do |attr_name| self.send(:"#{attr_name}=", (args[attr_name] || args[attr_name.to_s])) end end |
#create_xml(document) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 58 def create_xml(document) document.add "exceptId" do |except_element| except_element.set_attr "d", recurrence_id except_element.set_attr "tz", timezone except_element.set_attr "rangeType", range_type_to_zimbra if range_type end end |
#range_type=(val) ⇒ Object
29 30 31 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 29 def range_type=(val) @range_type = parse_range_type(val) end |
#range_type_to_zimbra ⇒ Object
54 55 56 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 54 def range_type_to_zimbra possible_range_type_values.find { |k, v| v == range_type }.first rescue range_type end |
#to_hash(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/zimbra/appointment/recur_exception.rb', line 44 def to_hash( = {}) hash = ATTRS.inject({}) do |attr_hash, attr_name| attr_hash[attr_name] = self.send(:"#{attr_name}") attr_hash end 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 |