Sha256: fb5db38955457a55463223b6a105bd7b23e317a78b009d47f96f3a68dfe611be

Contents?: true

Size: 961 Bytes

Versions: 24

Compression:

Stored size: 961 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(raw)}, response: #{raw}"
      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

24 entries across 24 versions & 1 rubygems

Version Path
cmis-ruby-0.5.38 lib/cmis/object_factory.rb
cmis-ruby-0.5.37 lib/cmis/object_factory.rb
cmis-ruby-0.5.36 lib/cmis/object_factory.rb
cmis-ruby-0.5.35 lib/cmis/object_factory.rb
cmis-ruby-0.5.34 lib/cmis/object_factory.rb
cmis-ruby-0.5.33 lib/cmis/object_factory.rb
cmis-ruby-0.5.32 lib/cmis/object_factory.rb
cmis-ruby-0.5.31 lib/cmis/object_factory.rb
cmis-ruby-0.5.30 lib/cmis/object_factory.rb
cmis-ruby-0.5.29 lib/cmis/object_factory.rb
cmis-ruby-0.5.28 lib/cmis/object_factory.rb
cmis-ruby-0.5.27 lib/cmis/object_factory.rb
cmis-ruby-0.5.26 lib/cmis/object_factory.rb
cmis-ruby-0.5.25 lib/cmis/object_factory.rb
cmis-ruby-0.5.24 lib/cmis/object_factory.rb
cmis-ruby-0.5.23 lib/cmis/object_factory.rb
cmis-ruby-0.5.22 lib/cmis/object_factory.rb
cmis-ruby-0.5.21 lib/cmis/object_factory.rb
cmis-ruby-0.5.20 lib/cmis/object_factory.rb
cmis-ruby-0.5.19 lib/cmis/object_factory.rb