Class: Sharepoint::Object
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
Instance Attribute Summary collapse
#data, #site, #updated_data
Instance Method Summary
collapse
#add_properties, #add_property, #available_properties
Constructor Details
#initialize(site, data) ⇒ 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
Returns the value of attribute fields.
10
11
12
|
# File 'lib/sharepoint-object.rb', line 10
def fields
@fields
end
|
Instance Attribute Details
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
|
126
127
128
129
130
131
|
# File 'lib/sharepoint-object.rb', line 126
def destroy
@site.query :post, resource_uri do |curl|
curl.['X-HTTP-Method'] = 'DELETE'
curl.['If-Match'] = __metadata['etag']
end
end
|
105
106
107
108
109
110
111
112
|
# File 'lib/sharepoint-object.rb', line 105
def guid
return @guid unless @guid.nil?
__metadata['id'].scan(/guid'([^']+)'/) do ||
@guid = $1
break
end
@guid
end
|
114
115
116
|
# File 'lib/sharepoint-object.rb', line 114
def reload
@site.query :get, __metadata['uri']
end
|
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
|