Class: Sharepoint::Object
- Inherits:
-
ObjectProperties
- Object
- ObjectProperties
- Sharepoint::Object
- Defined in:
- lib/sharepoint-object.rb
Direct Known Subclasses
ContextWebInformation, FeatureCollection, Field, File, FileVersion, Folder, GenericSharepointObject, Group, List, ListItem, PropertyValues, RoleAssignment, RoleDefinition, User, UserCustomAction, View, ViewFieldCollection, Web
Class Attribute Summary collapse
-
.fields ⇒ Object
Returns the value of attribute fields.
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Attributes inherited from ObjectProperties
Instance Method Summary collapse
- #copy(new_object = nil) ⇒ Object
- #destroy ⇒ Object
- #guid ⇒ Object
-
#initialize(site, data) ⇒ Object
constructor
A new instance of Object.
- #reload ⇒ Object
- #save ⇒ Object
Methods inherited from ObjectProperties
#add_properties, #add_property, #available_properties
Constructor Details
#initialize(site, data) ⇒ Object
Returns a new instance of Object.
100 101 102 103 |
# File 'lib/sharepoint-object.rb', line 100 def initialize site, data @parent = nil super site, data end |
Class Attribute Details
.fields ⇒ Object
Returns the value of attribute fields.
10 11 12 |
# File 'lib/sharepoint-object.rb', line 10 def fields @fields end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
98 99 100 |
# File 'lib/sharepoint-object.rb', line 98 def parent @parent end |
Instance Method Details
#copy(new_object = nil) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/sharepoint-object.rb', line 133 def copy new_object = nil updating = !new_object.nil? new_object ||= self.class.new @site self.class.fields.each do |field| next unless @data.keys.include? field[:name].to_s next if (field[:access] & [ :write, :initialize ]).count == 0 value = @data[field[:name].to_s] if updating == false new_object.data[field[:name].to_s] = value elsif new_object.data[field[:name].to_s] != value new_object.updated_data[field[:name].to_s] = value end end new_object end |
#destroy ⇒ Object
126 127 128 129 130 131 |
# File 'lib/sharepoint-object.rb', line 126 def destroy @site.query :post, resource_uri do |curl| curl.headers['X-HTTP-Method'] = 'DELETE' curl.headers['If-Match'] = ['etag'] end end |
#guid ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/sharepoint-object.rb', line 105 def guid return @guid unless @guid.nil? ['id'].scan(/guid'([^']+)'/) do || @guid = $1 break end @guid end |
#reload ⇒ Object
114 115 116 |
# File 'lib/sharepoint-object.rb', line 114 def reload @site.query :get, ['uri'] end |
#save ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/sharepoint-object.rb', line 118 def save if @data['__metadata'].nil? or @data['__metadata']['id'].nil? create elsif @updated_data.keys.count > 0 update end end |