-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎁 Introduce .named_derivatives_and_generators_filter
Prior to this commit, IIIF Print assumed that every file of a given mime-type would use all of the same generators. However, that is not necessarily the case. With this commit: - Updated documentation based on a read of the generated Yardoc - Added `DerivativeRodeoService.named_derivatives_and_generators_filter` - Added a `clone` of attributes The clone is in place to help ensure that as we apply the filter we don't accidentally delete the application's configuration for mime category and expected derivatives. For example, let's say I have the following nested hash: ```ruby nested_hash = { pdf: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator" }, image: { thumbnail: "DerivativeRodeo::Generators::ThumbnailGenerator", json: "DerivativeRodeo::Generators::WordCoordinatesGenerator", xml: "DerivativeRodeo::Generators::AltoGenerator", txt: "DerivativeRodeo::Generators::PlainTextGenerator" } } ``` If I then call the following: ```ruby nested_hash.fetch(:pdf).delete_if { |key, value| key == :thumbnail } ``` Then look at `nested_hash`, I will see the following: ```ruby pp nested_hash {:pdf=>{}, :image=> {:thumbnail=>"DerivativeRodeo::Generators::ThumbnailGenerator", :json=>"DerivativeRodeo::Generators::WordCoordinatesGenerator", :xml=>"DerivativeRodeo::Generators::AltoGenerator", :txt=>"DerivativeRodeo::Generators::PlainTextGenerator"}} ``` Why? Because we haven't changed objects. It's possible that Rails's class_attribute will do deep clones of hashes, but with this clone behavior we remove that possibility of a problem. Related to: - notch8/adventist-dl#684 - https://github.com/scientist-softserv/adventist-dl/issues/676
- Loading branch information
Showing
3 changed files
with
63 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters