Module: ActiveCMIS::Type

Defined in:
lib/active_cmis/type.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.create(param_conn, repository, klass_data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_cmis/type.rb', line 4

def self.create(param_conn, repository, klass_data)
  parent_id = klass_data.xpath("cra:type/c:parentId/text()", NS::COMBINED)
  superclass = if parent = parent_id.first
                 repository.type_by_id(parent.to_s)
               else
                 base_type_id = klass_data.xpath("cra:type/c:baseId", NS::COMBINED).text
                 case base_type_id
                 when "cmis:document"
                   Document
                 when "cmis:folder"
                   Folder
                 when "cmis:relationship" , "cmis:item"
                   Relationship
                 when "cmis:policy"
                   Policy
                 else
                   raise ActiveCMIS::Error.new("Type #{klass_data.xpath("cra:type/c:id", NS::COMBINED).text} without supertype, and not actually a valid base_type (#{base_type_id.inspect})\n" + klass_data.to_s)
                 end
               end

  klass = ::Class.new(superclass) do
    extend ActiveCMIS::Type::ClassMethods
    include ActiveCMIS::Type::InstanceMethods

    @repository = repository
    @conn = param_conn
    @data = klass_data
    @self_link = klass_data.xpath("at:link[@rel = 'self']/@href", NS::COMBINED).text

  end
  klass
end