Sha256: a233decef182ed1c9b61027512f414ba6a82a218bac2e97b5137498859ee0fe9

Contents?: true

Size: 938 Bytes

Versions: 35

Compression:

Stored size: 938 Bytes

Contents

module CMIS
  class ObjectFactory
    def self.create(raw, repository)
      case base_type_id(raw)
      when 'cmis:object' then Object.new(raw, repository)
      when 'cmis:folder' then Folder.new(raw, repository)
      when 'cmis:document' then Document.new(raw, repository)
      when 'cmis:relationship' then Relationship.new(raw, repository)
      when 'cmis:policy' then Policy.new(raw, repository)
      when 'cmis:item' then Item.new(raw, repository)
      else raise "Unexpected baseTypeId: #{base_type_id}"
      end
    end

    private

    def self.base_type_id(raw)
      if raw['properties'] && raw['properties']['cmis:baseTypeId']
        raw['properties']['cmis:baseTypeId']['value']
      elsif raw['succinctProperties'] && raw['succinctProperties']['cmis:baseTypeId']
        raw['succinctProperties']['cmis:baseTypeId']
      else
        'cmis:object' # no base type id, construct a poco
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
cmis-ruby-0.5.14 lib/cmis/object_factory.rb
cmis-ruby-0.5.13 lib/cmis/object_factory.rb
cmis-ruby-0.5.12 lib/cmis/object_factory.rb
cmis-ruby-0.5.11 lib/cmis/object_factory.rb
cmis-ruby-0.5.10 lib/cmis/object_factory.rb
cmis-ruby-0.5.9 lib/cmis/object_factory.rb
cmis-ruby-0.5.8 lib/cmis/object_factory.rb
cmis-ruby-0.5.7 lib/cmis/object_factory.rb
cmis-ruby-0.5.6 lib/cmis/object_factory.rb
cmis-ruby-0.5.5 lib/cmis/object_factory.rb
cmis-ruby-0.5.4 lib/cmis/object_factory.rb
cmis-ruby-0.5.3 lib/cmis/object_factory.rb
cmis-ruby-0.5.2 lib/cmis/object_factory.rb
cmis-ruby-0.5.1 lib/cmis/object_factory.rb
cmis-ruby-0.5 lib/cmis/object_factory.rb
cmis-ruby-0.4.11 lib/cmis/object_factory.rb
cmis-ruby-0.4.10 lib/cmis/object_factory.rb
cmis-ruby-0.4.9 lib/cmis/object_factory.rb
cmis-ruby-0.4.8 lib/cmis/object_factory.rb
cmis-ruby-0.4.7 lib/cmis/object_factory.rb