Class: YACCL::Model::Object
- Inherits:
-
Object
- Object
- YACCL::Model::Object
show all
- Defined in:
- lib/yaccl/model/object.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(repository_id, raw = {}) ⇒ Object
Returns a new instance of Object.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/yaccl/model/object.rb', line 23
def initialize(repository_id, raw={})
@repository_id = repository_id
@properties = get_properties_map(raw)
@cmis_object_id = @properties[:'cmis:objectId']
@base_type_id = @properties[:'cmis:baseTypeId']
@object_type_id = @properties[:'cmis:objectTypeId']
@secondary_object_type_ids = @properties[:'cmis:secondaryObjectTypeIds']
@name = @properties[:'cmis:name']
@description = @properties[:'cmis:description']
@created_by = @properties[:'cmis:createdBy']
@creation_date = @properties[:'cmis:creationDate']
@last_modified_by = @properties[:'cmis:lastModifiedBy']
@last_modification_date = @properties[:'cmis:lastModificationDate']
@change_token = @properties[:'cmis:changeToken']
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
126
127
128
|
# File 'lib/yaccl/model/object.rb', line 126
def method_missing(method_sym, *arguments, &block)
@properties[method_sym] ? @properties[method_sym] : super
end
|
Instance Attribute Details
#base_type_id ⇒ Object
Returns the value of attribute base_type_id.
6
7
8
|
# File 'lib/yaccl/model/object.rb', line 6
def base_type_id
@base_type_id
end
|
#change_token ⇒ Object
Returns the value of attribute change_token.
15
16
17
|
# File 'lib/yaccl/model/object.rb', line 15
def change_token
@change_token
end
|
#cmis_object_id ⇒ Object
Returns the value of attribute cmis_object_id.
5
6
7
|
# File 'lib/yaccl/model/object.rb', line 5
def cmis_object_id
@cmis_object_id
end
|
#created_by ⇒ Object
Returns the value of attribute created_by.
11
12
13
|
# File 'lib/yaccl/model/object.rb', line 11
def created_by
@created_by
end
|
#creation_date ⇒ Object
Returns the value of attribute creation_date.
12
13
14
|
# File 'lib/yaccl/model/object.rb', line 12
def creation_date
@creation_date
end
|
#description ⇒ Object
Returns the value of attribute description.
10
11
12
|
# File 'lib/yaccl/model/object.rb', line 10
def description
@description
end
|
#last_modification_date ⇒ Object
Returns the value of attribute last_modification_date.
14
15
16
|
# File 'lib/yaccl/model/object.rb', line 14
def last_modification_date
@last_modification_date
end
|
#last_modified_by ⇒ Object
Returns the value of attribute last_modified_by.
13
14
15
|
# File 'lib/yaccl/model/object.rb', line 13
def last_modified_by
@last_modified_by
end
|
Returns the value of attribute name.
9
10
11
|
# File 'lib/yaccl/model/object.rb', line 9
def name
@name
end
|
#object_type_id ⇒ Object
Returns the value of attribute object_type_id.
7
8
9
|
# File 'lib/yaccl/model/object.rb', line 7
def object_type_id
@object_type_id
end
|
#properties ⇒ Object
Returns the value of attribute properties.
16
17
18
|
# File 'lib/yaccl/model/object.rb', line 16
def properties
@properties
end
|
#repository_id ⇒ Object
Returns the value of attribute repository_id.
4
5
6
|
# File 'lib/yaccl/model/object.rb', line 4
def repository_id
@repository_id
end
|
#secondary_object_type_ids ⇒ Object
Returns the value of attribute secondary_object_type_ids.
8
9
10
|
# File 'lib/yaccl/model/object.rb', line 8
def secondary_object_type_ids
@secondary_object_type_ids
end
|
Instance Method Details
92
93
94
|
# File 'lib/yaccl/model/object.rb', line 92
def acls
Services.get_acl(repository_id, cmis_object_id, nil)
end
|
#add_aces(aces) ⇒ Object
96
97
98
|
# File 'lib/yaccl/model/object.rb', line 96
def add_aces(aces)
Services.apply_acl(repository_id, cmis_object_id, aces, nil, nil)
end
|
#can_be_deleted? ⇒ Boolean
114
115
116
|
# File 'lib/yaccl/model/object.rb', line 114
def can_be_deleted?
allowable_actions[:canDeleteObject]
end
|
#can_get_parents? ⇒ Boolean
118
119
120
|
# File 'lib/yaccl/model/object.rb', line 118
def can_get_parents?
allowable_actions[:canGetObjectParents]
end
|
#can_update_properties ⇒ Object
122
123
124
|
# File 'lib/yaccl/model/object.rb', line 122
def can_update_properties
allowable_actions[:canUpdateProperties]
end
|
#create_properties ⇒ Object
104
105
106
|
# File 'lib/yaccl/model/object.rb', line 104
def create_properties
{'cmis:name' => name, 'cmis:objectTypeId' => object_type_id}.merge(properties)
end
|
48
49
50
|
# File 'lib/yaccl/model/object.rb', line 48
def delete
Services.delete_object(repository_id, cmis_object_id, true)
end
|
#detached? ⇒ Boolean
108
109
110
|
# File 'lib/yaccl/model/object.rb', line 108
def detached?
cmis_object_id.nil?
end
|
#move(target_folder) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/yaccl/model/object.rb', line 83
def move(target_folder)
object_parents = parents
if object_parents.size == 1
Services.move_object(repository_id, cmis_object_id, target_folder.cmis_object_id, object_parents.first.cmis_object_id)
else
end
end
|
#object_id ⇒ Object
18
19
20
21
|
# File 'lib/yaccl/model/object.rb', line 18
def object_id
warn "[DEPRECATION] using `object_id` for CMIS objects is deprecated. Please use `cmis_object_id` instead."
cmis_object_id
end
|
#object_type ⇒ Object
44
45
46
|
# File 'lib/yaccl/model/object.rb', line 44
def object_type
repository.type(object_type_id)
end
|
72
73
74
75
76
|
# File 'lib/yaccl/model/object.rb', line 72
def policies
Services.get_applied_policies(repository_id, cmis_object_id, nil).map do |policy|
Policy.new(repository_id, policy)
end
end
|
#relationships(direction = :either) ⇒ Object
67
68
69
70
|
# File 'lib/yaccl/model/object.rb', line 67
def relationships(direction=:either)
result = Services.get_object_relationships(repository_id, cmis_object_id, nil, direction, nil, nil, false, nil, nil)
result[:objects].map { |r| Relationship.new(repository_id, r) }
end
|
#remove_aces(aces) ⇒ Object
100
101
102
|
# File 'lib/yaccl/model/object.rb', line 100
def remove_aces(aces)
Services.apply_acl(repository_id, cmis_object_id, nil, aces, nil)
end
|
#repository ⇒ Object
40
41
42
|
# File 'lib/yaccl/model/object.rb', line 40
def repository
Server.repository(repository_id)
end
|
#update_change_token(r) ⇒ Object
130
131
132
133
134
135
136
137
138
|
# File 'lib/yaccl/model/object.rb', line 130
def update_change_token(r)
@change_token = if r[:properties]
r[:properties][:'cmis:changeToken'][:value]
elsif r[:succinctProperties]
r[:succinctProperties][:'cmis:changeToken']
else
raise "Unexpected response: #{r}"
end
end
|
#update_properties(properties) ⇒ Object
52
53
54
55
|
# File 'lib/yaccl/model/object.rb', line 52
def update_properties(properties)
r = Services.update_properties(repository_id, cmis_object_id, change_token, properties)
update_change_token(r)
end
|