cocina-models 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e7900ad5ccfc3731276f0fbe6e27d77094b72b309e461206c46f41ff9b9a09d
4
- data.tar.gz: d5b1fbbd90d37daa1ac3538be417ae5ea61a8c7ec130ddbae842bb6d541fa806
3
+ metadata.gz: 6a9c692cb4e1534e826f25ebe4fc414eb083b0c26a52b7b17a10e01cc36d2323
4
+ data.tar.gz: 80fcae220c9fcaf922d836c3dd4383e2ee398a97a476ac40224e73a388ddd44f
5
5
  SHA512:
6
- metadata.gz: fdc52de4683d5e72207fe93902ecf207b2dea375be47d32599f69d2b11b9147cb27287032f6d1d7e87af991471c0680c23cc59927baa70cc62cc04cfb03ff8c3
7
- data.tar.gz: 173b81c88469efcc665af88943389a155e4c98f5de726c5087c8f44e59e313a26f5f3be22848d65ffdb269337ef987b91be328a2fd7107e1ccc16c5637b750de
6
+ metadata.gz: 8c92ac509185dd420a3cc78e040a92f9e5938263d456a8ab7355fc82c7ef3d7d9e1f57c612569bc5f8e849c6df6f58f18f5d9cf79ac2b35551c67833dc659c9c
7
+ data.tar.gz: fa690254b519dc3e4448e6d17c2fc0709f90db059d73f2a56ef725297b9b9c654abf8aca3b5505d4816bf1710fb8d37b4fcfad5184a01437fac335b97c270e89
@@ -6,6 +6,8 @@ module Cocina
6
6
  module Models
7
7
  # An admin policy object.
8
8
  class AdminPolicy < Dry::Struct
9
+ include Checkable
10
+
9
11
  TYPES = [
10
12
  Vocab.admin_policy
11
13
  ].freeze
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cocina
4
+ module Models
5
+ # A common interface for interrogating a model instance's type
6
+ module Checkable
7
+ def admin_policy?
8
+ (self.class::TYPES & AdminPolicy::TYPES).any?
9
+ end
10
+
11
+ def collection?
12
+ (self.class::TYPES & Collection::TYPES).any?
13
+ end
14
+
15
+ def dro?
16
+ (self.class::TYPES & DRO::TYPES).any?
17
+ end
18
+
19
+ def file?
20
+ (self.class::TYPES & File::TYPES).any?
21
+ end
22
+
23
+ def file_set?
24
+ (self.class::TYPES & FileSet::TYPES).any?
25
+ end
26
+ end
27
+ end
28
+ end
@@ -6,6 +6,8 @@ module Cocina
6
6
  module Models
7
7
  # A digital repository collection. See http://sul-dlss.github.io/cocina-models/maps/Collection.json
8
8
  class Collection < Dry::Struct
9
+ include Checkable
10
+
9
11
  TYPES = [
10
12
  Vocab.collection,
11
13
  Vocab.curated_collection,
@@ -6,6 +6,8 @@ module Cocina
6
6
  module Models
7
7
  # A digital repository object. See http://sul-dlss.github.io/cocina-models/maps/DRO.json
8
8
  class DRO < Dry::Struct
9
+ include Checkable
10
+
9
11
  TYPES = [
10
12
  Vocab.object,
11
13
  Vocab.three_dimensional,
@@ -6,6 +6,8 @@ module Cocina
6
6
  module Models
7
7
  # Metadata for a file. See http://sul-dlss.github.io/cocina-models/maps/File.json
8
8
  class File < Dry::Struct
9
+ include Checkable
10
+
9
11
  TYPES = [
10
12
  Vocab.file
11
13
  ].freeze
@@ -6,6 +6,8 @@ module Cocina
6
6
  module Models
7
7
  # Metadata for a File Set. See http://sul-dlss.github.io/cocina-models/maps/Fileset.json
8
8
  class FileSet < Dry::Struct
9
+ include Checkable
10
+
9
11
  TYPES = [
10
12
  Vocab.fileset
11
13
  ].freeze
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.8.0'
5
+ VERSION = '0.9.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -171,6 +171,7 @@ files:
171
171
  - docs/sampleETD/xn109qc9773_taco.json
172
172
  - lib/cocina/models.rb
173
173
  - lib/cocina/models/admin_policy.rb
174
+ - lib/cocina/models/checkable.rb
174
175
  - lib/cocina/models/collection.rb
175
176
  - lib/cocina/models/dro.rb
176
177
  - lib/cocina/models/file.rb