Class: CMIS::ObjectFactory
- Inherits:
-
Object
- Object
- CMIS::ObjectFactory
- Defined in:
- lib/cmis/object_factory.rb
Class Method Summary collapse
Class Method Details
.base_type_id(raw) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/cmis/object_factory.rb', line 17 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 |
.create(raw, repository) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/cmis/object_factory.rb', line 3 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 |