Class: Exchanger::BaseFolder

Inherits:
Element
  • Object
show all
Defined in:
lib/exchanger/elements/base_folder.rb

Overview

Abstract folder class

Constant Summary collapse

DISTINGUISHED_NAMES =

Folders that can be referenced by name. msdn.microsoft.com/en-us/library/aa580808.aspx

[
  :inbox, :outbox, :drafts, :deleteditems, :sentitems, :junkemail,
  :calendar, :contacts, :tasks, :notes, :journal,
  :msgfolderroot, :publicfoldersroot, :root,
  :searchfolders, :voicemail
]

Instance Attribute Summary collapse

Attributes inherited from Element

#tag_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#==, #assign_attributes_from_xml, create_element_accessors, element, #errors, #initialize, #inspect, key, new_from_xml, #to_xml, #to_xml_change, #to_xml_updates

Methods included from Persistence

#destroy, #new_record?, #persisted?, #reload, #save

Methods included from Dirty

#attribute_change, #attribute_changed?, #attribute_was, #changed, #changed?, #changes, included, #move_changes, #previous_changes, #reset_attribute!, #reset_modifications, #setup_modifications

Methods included from Attributes

#attributes, #attributes=, #change_key, #id, #identifier, #method_missing, #read_attribute, #respond_to?, #write_attribute

Constructor Details

This class inherits a constructor from Exchanger::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Exchanger::Attributes

Instance Attribute Details

#parent_folderObject



42
43
44
45
46
# File 'lib/exchanger/elements/base_folder.rb', line 42

def parent_folder
  @parent_folder ||= if parent_folder_id
    Folder.find(parent_folder_id.id)
  end
end

Class Method Details

.find(id, email_address = nil) ⇒ Object



26
27
28
# File 'lib/exchanger/elements/base_folder.rb', line 26

def self.find(id, email_address = nil)
  find_all([id], email_address).first
end

.find_all(ids, email_address = nil) ⇒ Object



30
31
32
33
# File 'lib/exchanger/elements/base_folder.rb', line 30

def self.find_all(ids, email_address = nil)
  response = GetFolder.run(:folder_ids => ids, :email_address => email_address)
  response.folders
end

.find_all_by_parent_id(parent_id) ⇒ Object



35
36
37
38
# File 'lib/exchanger/elements/base_folder.rb', line 35

def self.find_all_by_parent_id(parent_id)
  response = FindFolder.run(:parent_folder_id => parent_id)
  response.folders
end

Instance Method Details

#category_listObject



70
71
72
# File 'lib/exchanger/elements/base_folder.rb', line 70

def category_list
  @category_list ||= GetUserConfiguration.run(folder_id: id, user_configuration_name: "CategoryList").configuration.category_list
end

#expanded_items(calendar_view_options) ⇒ Object

Return items (also recurring calendar items) based on provided CalendarView options



63
64
65
66
67
68
# File 'lib/exchanger/elements/base_folder.rb', line 63

def expanded_items(calendar_view_options)
  calendar_view = CalendarView.new(calendar_view_options)
  items = Item.find_calendar_view_set_by_folder_id(id, calendar_view)

  items.each { |item| item.parent_folder = self }
end

#foldersObject

Sub folders



49
50
51
52
53
# File 'lib/exchanger/elements/base_folder.rb', line 49

def folders
  self.class.find_all_by_parent_id(id).each do |folder|
    folder.parent_folder = self
  end
end

#itemsObject



55
56
57
58
59
# File 'lib/exchanger/elements/base_folder.rb', line 55

def items
  Item.find_all_by_folder_id(id).each do |item|
    item.parent_folder = self
  end
end