lib/cocina/models/dro.rb in cocina-models-0.3.0 vs lib/cocina/models/dro.rb in cocina-models-0.4.0
- old
+ new
@@ -4,25 +4,54 @@
module Cocina
module Models
# A digital repository object. See https://github.com/sul-dlss-labs/taco/blob/master/maps/DRO.json
class DRO < Dry::Struct
+ # Subschema for release tags
+ class ReleaseTag < Dry::Struct
+ attribute :to, Types::Strict::String
+ attribute :what, Types::Strict::String.enum('self', 'collection')
+ # we use 'when' other places, but that's reserved word, so 'date' it is!
+ attribute :date, Types::Params::DateTime
+ attribute :who, Types::Strict::String
+ attribute :release, Types::Params::Bool
+ end
+
+ # Subschema for access concerns
+ class Access < Dry::Struct
+ attribute :embargoReleaseDate, Types::Params::DateTime.meta(omittable: true)
+ end
+
+ # Subschema for administrative concerns
+ class Administrative < Dry::Struct
+ attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).meta(omittable: true)
+ end
+
+ class Identification < Dry::Struct
+ end
+
+ class Structural < Dry::Struct
+ end
+
attribute :externalIdentifier, Types::Strict::String
attribute :type, Types::Strict::String
attribute :label, Types::Strict::String
- attribute :access, Dry::Struct.meta(omittable: true) do
- attribute :embargoReleaseDate, Types::Params::DateTime
- end
+ attribute :version, Types::Strict::Integer
+ attribute(:access, Access.default { Access.new })
+ attribute(:administrative, Administrative.default { Administrative.new })
+ attribute(:identification, Identification.default { Identification.new })
+ attribute(:structural, Structural.default { Structural.new })
- def self.from_dynamic(d)
+ def self.from_dynamic(dyn)
params = {
- externalIdentifier: d['externalIdentifier'],
- type: d['type'],
- label: d['label']
+ externalIdentifier: dyn['externalIdentifier'],
+ type: dyn['type'],
+ label: dyn['label'],
+ version: dyn['version']
}
- if d['access']
+ if dyn['access']
access = {
- embargoReleaseDate: d['access']['embargoReleaseDate']
+ embargoReleaseDate: dyn['access']['embargoReleaseDate']
}
params[:access] = access
end
DRO.new(params)