Class: YACCL::Model::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/yaccl/model/object.rb

Direct Known Subclasses

Document, Folder, Item, Policy, Relationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository_id, raw = {}) ⇒ Object

Returns a new instance of Object.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yaccl/model/object.rb', line 18

def initialize(repository_id, raw={})
  @repository_id = repository_id
  @properties = get_properties_map(raw)

  @object_id = @properties[:'cmis:objectId']
  @base_type_id = @properties[:'cmis:baseTypeId']
  @object_type_id = @properties[:'cmis:objectTypeId']
  @secondary_object_type_ids = @properties[:'cmis:secondaryObjectTypeId']
  @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



120
121
122
# File 'lib/yaccl/model/object.rb', line 120

def method_missing(method_sym, *arguments, &block)
  @properties[method_sym] ? @properties[method_sym] : super
end

Instance Attribute Details

#base_type_idObject (readonly)

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_tokenObject (readonly)

Returns the value of attribute change_token.



15
16
17
# File 'lib/yaccl/model/object.rb', line 15

def change_token
  @change_token
end

#created_byObject (readonly)

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_dateObject (readonly)

Returns the value of attribute creation_date.



12
13
14
# File 'lib/yaccl/model/object.rb', line 12

def creation_date
  @creation_date
end

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/yaccl/model/object.rb', line 10

def description
  @description
end

#last_modification_dateObject (readonly)

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_byObject (readonly)

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

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/yaccl/model/object.rb', line 9

def name
  @name
end

#object_idObject (readonly)

Returns the value of attribute object_id.



5
6
7
# File 'lib/yaccl/model/object.rb', line 5

def object_id
  @object_id
end

#object_type_idObject

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

#propertiesObject

Returns the value of attribute properties.



16
17
18
# File 'lib/yaccl/model/object.rb', line 16

def properties
  @properties
end

#repository_idObject (readonly)

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_idsObject (readonly)

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

#aclsObject



86
87
88
# File 'lib/yaccl/model/object.rb', line 86

def acls
  Services.get_acl(repository_id, object_id, nil)
end

#add_aces(aces) ⇒ Object



90
91
92
# File 'lib/yaccl/model/object.rb', line 90

def add_aces(aces)
  Services.apply_acl(repository_id, object_id, aces, nil, nil)
end

#allowable_actionsObject



57
58
59
# File 'lib/yaccl/model/object.rb', line 57

def allowable_actions
  Services.get_allowable_actions(repository_id, object_id)
end

#can_be_deleted?Boolean

utility

Returns:

  • (Boolean)


108
109
110
# File 'lib/yaccl/model/object.rb', line 108

def can_be_deleted?
  allowable_actions[:canDeleteObject]
end

#can_get_parents?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/yaccl/model/object.rb', line 112

def can_get_parents?
  allowable_actions[:canGetObjectParents]
end

#can_update_propertiesObject



116
117
118
# File 'lib/yaccl/model/object.rb', line 116

def can_update_properties
  allowable_actions[:canUpdateProperties]
end

#create_propertiesObject



98
99
100
# File 'lib/yaccl/model/object.rb', line 98

def create_properties
  {'cmis:name' => name, 'cmis:objectTypeId' => object_type_id}.merge(properties)
end

#deleteObject



43
44
45
# File 'lib/yaccl/model/object.rb', line 43

def delete
  Services.delete_object(repository_id, object_id, true)
end

#detached?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/yaccl/model/object.rb', line 102

def detached?
  object_id.nil?
end

#move(target_folder) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/yaccl/model/object.rb', line 77

def move(target_folder)
  object_parents = parents
  if object_parents.size == 1
    Services.move_object(repository_id, object_id, target_folder.object_id, object_parents.first.object_id)
  else
    # raise?
  end
end

#object_typeObject



39
40
41
# File 'lib/yaccl/model/object.rb', line 39

def object_type
  repository.type(object_type_id)
end

#parentsObject



51
52
53
54
55
# File 'lib/yaccl/model/object.rb', line 51

def parents
  Services.get_object_parents(repository_id, object_id, nil, nil, nil, nil, nil).map do |o|
    ObjectFactory.create(repository_id, o[:object])
  end
end

#policiesObject



66
67
68
69
70
# File 'lib/yaccl/model/object.rb', line 66

def policies
  Services.get_applied_policies(repository_id, object_id, nil).map do |policy|
    Policy.new(repository_id, policy)
  end
end

#relationships(direction = :either) ⇒ Object



61
62
63
64
# File 'lib/yaccl/model/object.rb', line 61

def relationships(direction=:either)
  result = Services.get_object_relationships(repository_id, object_id, nil, direction, nil, nil, false, nil, nil)
  result[:objects].map { |r| Relationship.new(repository_id, r) }
end

#remove_aces(aces) ⇒ Object



94
95
96
# File 'lib/yaccl/model/object.rb', line 94

def remove_aces(aces)
  Services.apply_acl(repository_id, object_id, nil, aces, nil)
end

#repositoryObject



35
36
37
# File 'lib/yaccl/model/object.rb', line 35

def repository
  Server.repository(repository_id)
end

#unfileObject

remove from all folders



73
74
75
# File 'lib/yaccl/model/object.rb', line 73

def unfile
  Services.remove_object_from_folder(repository_id, object_id, nil)
end

#update_properties(properties) ⇒ Object



47
48
49
# File 'lib/yaccl/model/object.rb', line 47

def update_properties(properties)
  Services.update_properties(repository_id, object_id, nil, properties)
end