Class: SdrClient::RedesignedClient::RequestBuilder
- Inherits:
-
Object
- Object
- SdrClient::RedesignedClient::RequestBuilder
- Defined in:
- lib/sdr_client/redesigned_client/request_builder.rb
Overview
Builds a Cocina request object from metadata. This is what we send to the server when doing a deposit.
Instance Attribute Summary collapse
-
#file_sets ⇒ Object
writeonly
Sets the attribute file_sets.
Instance Method Summary collapse
-
#for(filename) ⇒ Hash
The metadata for the file.
-
#initialize(apo:, source_id:, **options) ⇒ RequestBuilder
constructor
Additional metadata includes access, preserve, shelve, publish, md5, sha1.
- #to_cocina ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(apo:, source_id:, **options) ⇒ RequestBuilder
Additional metadata includes access, preserve, shelve, publish, md5, sha1
27 28 29 30 31 |
# File 'lib/sdr_client/redesigned_client/request_builder.rb', line 27 def initialize(apo:, source_id:, **) @apo = apo @source_id = source_id @options = end |
Instance Attribute Details
#file_sets=(value) ⇒ Object
Sets the attribute file_sets
65 66 67 |
# File 'lib/sdr_client/redesigned_client/request_builder.rb', line 65 def file_sets=(value) @file_sets = value end |
Instance Method Details
#for(filename) ⇒ Hash
Returns the metadata for the file.
51 52 53 54 55 56 57 58 59 |
# File 'lib/sdr_client/redesigned_client/request_builder.rb', line 51 def for(filename) .fetch(filename, {}) .with_indifferent_access .tap do || [:view] = view unless .key?(:view) [:download] = download unless .key?(:download) end end |
#to_cocina ⇒ Object
45 46 47 |
# File 'lib/sdr_client/redesigned_client/request_builder.rb', line 45 def to_cocina Cocina::Models.build_request(to_h.with_indifferent_access) end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sdr_client/redesigned_client/request_builder.rb', line 33 def to_h { access: access_struct, type: type, administrative: administrative, identification: identification, structural: structural, version: 1, label: label.nil? ? ':auto' : label } end |
#type ⇒ Object
61 62 63 |
# File 'lib/sdr_client/redesigned_client/request_builder.rb', line 61 def type .fetch(:type, Cocina::Models::ObjectType.object) end |