Class: Exchanger::Attachment

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

Direct Known Subclasses

FileAttachment, ItemAttachment

Instance Attribute Summary collapse

Attributes inherited from Element

#tag_name

Class Method Summary collapse

Methods inherited from Element

#==, #assign_attributes_from_xml, create_element_accessors, element, #errors, #initialize, #inspect, key, #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_item_idObject

Returns the value of attribute parent_item_id.



14
15
16
# File 'lib/exchanger/elements/attachment.rb', line 14

def parent_item_id
  @parent_item_id
end

Class Method Details

.find(id) ⇒ Object



16
17
18
# File 'lib/exchanger/elements/attachment.rb', line 16

def self.find(id)
  find_all([id]).first
end

.find_all(ids) ⇒ Object



20
21
22
23
# File 'lib/exchanger/elements/attachment.rb', line 20

def self.find_all(ids)
  response = GetAttachment.run(attachment_ids: ids)
  response.attachments
end

.new_from_xml(xml) ⇒ Object

The “Attachments” element contains the items or files that are attached to an item in the Exchange store.

<Attachments>
  <ItemAttachment/>
  <FileAttachment/>
</Attachments>

msdn.microsoft.com/en-us/library/office/aa564869(v=exchg.150).aspx

Determine if the given XML node contains an ItemAttachment or FileAttachment and initialize the new instance.



36
37
38
39
# File 'lib/exchanger/elements/attachment.rb', line 36

def self.new_from_xml(xml)
  attachment_subclass = Exchanger.const_get(xml.name)
  attachment_subclass.new.assign_attributes_from_xml(xml)
end