cocina-models 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocina/models.rb +20 -3
- data/lib/cocina/models/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: 6579b5a67f571fcdc927fc706ede76393f43ebd308afa239c5af2b51d002cbc7
|
4
|
+
data.tar.gz: 3cf796d0d505cece4aa1f168ce3d7fdc5d3f3430cc452aec55678e0fad756c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfd14169ccf6c62d828642dd806030bc456f1838e3891b8205570f72782e47cbe3bc10b50fa175ae52bbaeafb5fd6b0bd9d756d42f08c22ef41075b682c9629b
|
7
|
+
data.tar.gz: 1503063b275634492bd6bd050c170989c01cd0051fa133bc2c9a6999b71eede591a1a3da7040d57f19ff62fe2c71f39d9c77cffbf59e1f4a510b2ee87d1d80f6
|
data/lib/cocina/models.rb
CHANGED
@@ -48,11 +48,28 @@ module Cocina
|
|
48
48
|
def self.build(dyn)
|
49
49
|
case dyn.fetch('type')
|
50
50
|
when *DRO::TYPES
|
51
|
-
DRO.
|
51
|
+
DRO.new(dyn)
|
52
52
|
when *Collection::TYPES
|
53
|
-
Collection.
|
53
|
+
Collection.new(dyn)
|
54
54
|
when *AdminPolicy::TYPES
|
55
|
-
AdminPolicy.
|
55
|
+
AdminPolicy.new(dyn)
|
56
|
+
else
|
57
|
+
raise UnknownTypeError, "Unknown type: '#{dyn.fetch('type')}'"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# @param [Hash] dyn a ruby hash representation of the JSON serialization of a request for a Collection or DRO
|
62
|
+
# @return [RequestDRO,RequestCollection,RequestAdminPolicy]
|
63
|
+
# @raises [UnknownTypeError] if a valid type is not found in the data
|
64
|
+
# @raises [KeyError] if a type field cannot be found in the data
|
65
|
+
def self.build_request(dyn)
|
66
|
+
case dyn.fetch('type')
|
67
|
+
when *DRO::TYPES
|
68
|
+
RequestDRO.new(dyn)
|
69
|
+
when *Collection::TYPES
|
70
|
+
RequestCollection.new(dyn)
|
71
|
+
when *AdminPolicy::TYPES
|
72
|
+
RequestAdminPolicy.new(dyn)
|
56
73
|
else
|
57
74
|
raise UnknownTypeError, "Unknown type: '#{dyn.fetch('type')}'"
|
58
75
|
end
|