Class: Exchanger::BaseFolder

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

Overview

Abstract folder class

Direct Known Subclasses

CalendarFolder, ContactsFolder, Folder, SearchFolder, TasksFolder

Constant Summary

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

#==, 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?, #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

- (Object) parent_folder



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

+ (Object) find(id, email_address = nil)



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

+ (Object) find_all(ids, email_address = nil)



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

+ (Object) find_all_by_parent_id(parent_id)



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

- (Object) folders

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

- (Object) items



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