Sha256: 100bebf66fd236a578d1f90876979d097e416f07cf33ac7403eb303af45117ca

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module Cocina
  module Models
    # A request to create a file.
    # This is same as a File, but without externalIdentifier (as that wouldn't have been created yet)
    # See http://sul-dlss.github.io/cocina-models/maps/File.json
    class RequestFile < Struct
      attribute(:access, File::Access.optional.default { File::Access.new })
      attribute(:administrative, File::Administrative.default { File::Administrative.new })
      attribute :type, Types::String.enum(*File::TYPES)
      attribute :label, Types::Strict::String
      attribute :filename, Types::String.optional.default(nil)
      attribute :use, Types::String.enum('transcription').optional.meta(omittable: true)
      attribute :size, Types::Coercible::Integer.optional.default(nil)
      attribute :hasMessageDigests, Types::Strict::Array.of(File::Fixity).default([].freeze)
      attribute :hasMimeType, Types::String.optional.meta(omittable: true)
      attribute(:presentation, File::Presentation.optional.meta(omittable: true))
      attribute :version, Types::Coercible::Integer
      attribute(:identification, File::Identification.optional.meta(omittable: true))
      attribute(:structural, File::Structural.optional.meta(omittable: true))

      def self.from_dynamic(dyn)
        new(dyn)
      end

      def self.from_json(json)
        from_dynamic(JSON.parse(json))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocina-models-0.25.0 lib/cocina/models/request_file.rb
cocina-models-0.24.0 lib/cocina/models/request_file.rb