Class: CmisServer::RenderableCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/cmis_server/renderable_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_object:, items:, atompub_properties: nil) ⇒ RenderableCollection

Returns a new instance of RenderableCollection.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cmis_server/renderable_collection.rb', line 9

def initialize(base_object:, items:, atompub_properties: nil)
  @base_object=base_object
  @items      =items
  if atompub_properties
    @atompub_properties={
        id:      atompub_properties[:id]||SecureRandom.uuid,
        title:   atompub_properties[:title]||'Collection',
        edited:  atompub_properties[:edited]||DateTime.now,
        updated: atompub_properties[:updated]||DateTime.now,
        author:  atompub_properties[:author]||'Unknown',
    }
  end
end

Instance Attribute Details

#base_objectObject (readonly)

Returns the value of attribute base_object.



6
7
8
# File 'lib/cmis_server/renderable_collection.rb', line 6

def base_object
  @base_object
end

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/cmis_server/renderable_collection.rb', line 7

def items
  @items
end

Instance Method Details

#atompub_propertiesObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cmis_server/renderable_collection.rb', line 27

def atompub_properties
  return @atompub_properties if @atompub_properties
  if @base_object
    # Gérer le cas où @base_object peut être un RenderableObject ou un Adapter
    if @base_object.respond_to?(:base_object)
      # C'est un RenderableObject
      base_obj = @base_object.base_object
    elsif @base_object.respond_to?(:object)
      # C'est un Adapter
      base_obj = @base_object.object
    else
      # C'est un objet de base
      base_obj = @base_object
    end
    
    {
        id:      base_obj.cmis_object_id,
        title:   base_obj.cmis_name,
        edited:  DateTime.now,
        updated: DateTime.now,
        author:  'unknown',
    }
  else
    # Cas du root folder virtuel
    {
        id:      'root_folder_collection',
        title:   'Root Folders',
        edited:  DateTime.now,
        updated: DateTime.now,
        author:  'Core System',
    }
  end
end

#filter_properties!(filter) ⇒ Object



23
24
25
# File 'lib/cmis_server/renderable_collection.rb', line 23

def filter_properties!(filter)
  @properties=@properties.slice(*filter)
end

#total_items_countObject



61
62
63
# File 'lib/cmis_server/renderable_collection.rb', line 61

def total_items_count
  nil
end