sul-dlss / cocina-models

Cocina repository data model (implemented in Ruby)
https://sul-dlss.github.io/cocina-models/
3 stars 0 forks source link

[SPIKE] Create an interface for effectively mutating model instances #303

Closed mjgiarlo closed 2 years ago

mjgiarlo commented 2 years ago

Working with our cocina-models can be jarring because, unlike most of the rest of the code we write, dry-structs are immutable which can lead to surprising results when leaning on the usual assignment interactions. So, try something different. What is in this commit (which is partly copypasta from a dry-struct issue) works fine in the simplest use cases (see administrative spec), but currently fails in the gnarlier use cases (file access spec) particularly when reaching into a structure (like a DRO) to modify another structure (like a File). Why? Because File instances are not self-validating. Files are validated in the context of the DRO, and when you reach into the DRO and mutate the File, I have so far not found a way to force a validation in the surrounding context. This feels a lot like working against dry-struct/-types, too, so I am ending the spike and pushing this up for comments.

justinlittman commented 2 years ago

@mjgiarlo Can this be closed?

mjgiarlo commented 2 years ago

@justinlittman Yep!