Class: YACCL::Model::Folder

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

Instance Attribute Summary collapse

Attributes inherited from Object

#base_type_id, #change_token, #created_by, #creation_date, #description, #last_modification_date, #last_modified_by, #name, #object_id, #object_type_id, #properties, #repository_id, #secondary_object_type_ids

Instance Method Summary collapse

Methods inherited from Object

#acls, #add_aces, #allowable_actions, #can_be_deleted?, #can_get_parents?, #can_update_properties, #create_properties, #delete, #detached?, #method_missing, #move, #object_type, #parents, #policies, #relationships, #remove_aces, #repository, #unfile, #update_properties

Constructor Details

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

Returns a new instance of Folder.



8
9
10
11
12
13
# File 'lib/yaccl/model/folder.rb', line 8

def initialize(repository_id, raw={})
  super
  @parent_id = @properties[:'cmis:parentId']
  @path = @properties[:'cmis:path']
  @allowed_child_object_type_ids = @properties[:'cmis:allowedChildObjectTypeIds']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class YACCL::Model::Object

Instance Attribute Details

#allowed_child_object_type_idsObject (readonly)

Returns the value of attribute allowed_child_object_type_ids.



6
7
8
# File 'lib/yaccl/model/folder.rb', line 6

def allowed_child_object_type_ids
  @allowed_child_object_type_ids
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



4
5
6
# File 'lib/yaccl/model/folder.rb', line 4

def parent_id
  @parent_id
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#add(object) ⇒ Object



60
61
62
# File 'lib/yaccl/model/folder.rb', line 60

def add(object)
  Services.add_object_to_folder(repository_id, object.object_id, object_id, nil)
end

#allowed_child_object_typesObject



19
20
21
22
23
24
# File 'lib/yaccl/model/folder.rb', line 19

def allowed_child_object_types
  return nil if allowed_child_object_type_ids.nil?
  allowed_child_object_type_ids.map do |type_id|
    repository.type(type_id)
  end
end

#childrenObject



26
27
28
29
30
31
32
33
# File 'lib/yaccl/model/folder.rb', line 26

def children
  children = Services.get_children(repository_id, object_id, nil, nil, nil, nil, nil, nil, nil, nil)
  if children.has_key?(:objects)
    children[:objects].map { |o| ObjectFactory.create(repository_id, o[:object]) }
  else
    []
  end
end

#create(object) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/yaccl/model/folder.rb', line 38

def create(object)
  properties = object.create_properties
  if object.is_a? Folder
    o = Services.create_folder(repository_id, properties, object_id, nil, nil, nil)
  elsif object.is_a? Document
    return object.create_in_folder(object_id)
  elsif object.is_a? Relationship
    raise 'relationship is not fileable'
  elsif object.is_a? Policy
    o = Services.create_policy(repository_id, properties, object_id, nil, nil, nil)
  elsif object.is_a? Item
    o = Services.create_item(repository_id, properties, object_id, nil, nil, nil)
  else
    raise "Unexpected base_type_id: #{object.base_type_id}"
  end
  ObjectFactory.create(repository_id, o)
end

#delete_treeObject



56
57
58
# File 'lib/yaccl/model/folder.rb', line 56

def delete_tree
  Services.delete_tree(repository_id, object_id, true, false, false)
end

#parentObject



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

def parent
  repository.object(parent_id) unless parent_id.nil?
end

#remove(object) ⇒ Object



64
65
66
# File 'lib/yaccl/model/folder.rb', line 64

def remove(object)
  Services.remove_object_from_folder(repository_id, object.object_id, object_id)
end

#tree(depth) ⇒ Object



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

def tree(depth)
end