Class: Samvera::Derivatives::Configuration
- Inherits:
-
Object
- Object
- Samvera::Derivatives::Configuration
- Defined in:
- lib/samvera/derivatives/configuration.rb
Overview
The implicit deriviate types for Hyrax are as follows:
-
type :extracted_text with sources [:pdf, :office_document]
-
type :thumbnail with sources [:pdf, :office_document, :thumbnail, :image]
-
type :mp3 with sources [:audio]
-
type :ogg with sources [:audio]
-
type :webm with sources [:video]
-
type :mp4 with sources [:video]
A long-standing practice of Samvera’s Hyrax has been to have assumptive and implicit derivative generation (see Hyrax::FileSetDerivativesService). In being implicit, a challenge arises, namely overriding and configuring. There exists a crease in the code to allow for a different derivative approach (see Hyrax::DerivativeService). Yet that approach continues the tradition of implicit work.
The purpose of this class is to contain the explicit derivative generation directives for the upstream application.
Defined Under Namespace
Classes: RegisteredType
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #register(type:, locators:, applicators:) {|applicability| ... } ⇒ RegisteredType
- #registry_for(type:) ⇒ RegisteredType
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 27 |
# File 'lib/samvera/derivatives/configuration.rb', line 23 def initialize # Favoring a Hash for ease of lookup as well as the concept that there can be only one entry # per type. @registered_types = {} end |
Instance Method Details
#register(type:, locators:, applicators:) {|applicability| ... } ⇒ RegisteredType
What is the best mechanism for naming the sources? At present we’re doing a lot of assumption on the types.
51 52 53 54 55 56 57 58 59 |
# File 'lib/samvera/derivatives/configuration.rb', line 51 def register(type:, locators:, applicators:, &applicability) # Should the validator be required? @registered_types[type.to_sym] = RegisteredType.new( type: type.to_sym, locators: Array(locators), applicators: Array(applicators), applicability: applicability || default_applicability ) end |
#registry_for(type:) ⇒ RegisteredType
67 68 69 |
# File 'lib/samvera/derivatives/configuration.rb', line 67 def registry_for(type:) @registered_types.fetch(type.to_sym) { empty_registry_for(type: type.to_sym) } end |