restful-sharepoint 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restful-sharepoint/common-base.rb +6 -7
- data/lib/restful-sharepoint/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d457fe2a3101a2804ff42572417f3df0cb9aaa550566384ddeb2abc48e123de6
|
4
|
+
data.tar.gz: dab1ddd69bfeba89a82ec286fe75bc4f9f6c7f7b130a6af71f4cab664d07046b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4142d847ed5da39ffb538671b3ce23795a1679ff0f03e3e29958f73288f5a5bb427732005b92880641be7a3f28a9faa22731f02e074082b51407484f7a818c4
|
7
|
+
data.tar.gz: f5dbacb4e4d3a2cee8abf1a23d3bfa73343c2213ac4e0bf8894b7a0493e9fe0dba826b1310e3d76756f594489826bee58546df59ecd98b4890ecc17fa94868a8
|
@@ -2,16 +2,15 @@ module RestfulSharePoint
|
|
2
2
|
class CommonBase
|
3
3
|
# Converts the given enumerable tree to a collection or object.
|
4
4
|
def objectify(tree)
|
5
|
-
klass = nil
|
6
5
|
if tree['results'] && !tree['results'].empty?
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
type = tree.dig('__metadata', 'type') || tree.dig('results', 0, '__metadata', 'type')
|
7
|
+
raise "Object type not specified" unless type
|
8
|
+
pattern, klass = COLLECTION_MAP.find { |pattern,| pattern.match(type) }
|
10
9
|
klass ? RestfulSharePoint.const_get(klass).new(parent: self, collection: tree['results']) : tree['results']
|
11
10
|
elsif tree['__metadata']
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
type = tree['__metadata']['type']
|
12
|
+
raise "Collection type not specified" unless type
|
13
|
+
pattern, klass = OBJECT_MAP.find { |pattern,| pattern.match(type) }
|
15
14
|
klass ? RestfulSharePoint.const_get(klass).new(parent: self, properties: tree) : tree
|
16
15
|
end
|
17
16
|
end
|