Class: Samvera::Derivatives::Hyrax::ServiceShim
- Inherits:
-
Object
- Object
- Samvera::Derivatives::Hyrax::ServiceShim
- Defined in:
- lib/samvera/derivatives/hyrax.rb
Overview
Note:
This conforms to the Hyrax::DerivativeService interface. The intention of this class is to be the sole registered Hyrax::DerivativeService.services
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
- #derivatives ⇒ Array<Samvera::Derivatives::Configuration::RegisteredType> readonly
-
#file_set ⇒ Object
readonly
Returns the value of attribute file_set.
Instance Method Summary collapse
- #cleanup_derivatives ⇒ Object
-
#create_derivatives(file_path) ⇒ Object
We have two vectors of consideration for derivative generation:.
- #derivative_url(_destination_name) ⇒ Object
-
#initialize(file_set, candidate_derivative_types: [], config: Samvera::Derivatives.config) ⇒ ServiceShim
constructor
A new instance of ServiceShim.
- #valid? ⇒ Boolean
Constructor Details
#initialize(file_set, candidate_derivative_types: [], config: Samvera::Derivatives.config) ⇒ ServiceShim
20 21 22 23 24 |
# File 'lib/samvera/derivatives/hyrax.rb', line 20 def initialize(file_set, candidate_derivative_types: [], config: Samvera::Derivatives.config) @file_set = file_set @config = config @derivatives = candidate_derivative_types.map { |type| config.registry_for(type: type) } end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
30 31 32 |
# File 'lib/samvera/derivatives/hyrax.rb', line 30 def config @config end |
#derivatives ⇒ Array<Samvera::Derivatives::Configuration::RegisteredType> (readonly)
29 30 31 |
# File 'lib/samvera/derivatives/hyrax.rb', line 29 def derivatives @derivatives end |
#file_set ⇒ Object (readonly)
Returns the value of attribute file_set.
26 27 28 |
# File 'lib/samvera/derivatives/hyrax.rb', line 26 def file_set @file_set end |
Instance Method Details
#cleanup_derivatives ⇒ Object
39 |
# File 'lib/samvera/derivatives/hyrax.rb', line 39 def cleanup_derivatives; end |
#create_derivatives(file_path) ⇒ Object
We have two vectors of consideration for derivative generation:
-
The desired derivatives for a file_set’s parent work (e.g. the candidate derivatives)
-
The available derivatives for a file_set’s mime type
45 46 47 48 49 50 51 52 53 |
# File 'lib/samvera/derivatives/hyrax.rb', line 45 def create_derivatives(file_path) derivatives.each do |derivative| Samvera::Derivatives.locate_and_apply_derivative_for( file_set: file_set, file_path: file_path, derivative: derivative ) end end |
#derivative_url(_destination_name) ⇒ Object
55 56 57 |
# File 'lib/samvera/derivatives/hyrax.rb', line 55 def derivative_url(_destination_name) "" end |
#valid? ⇒ Boolean
32 33 34 35 36 37 |
# File 'lib/samvera/derivatives/hyrax.rb', line 32 def valid? # We have a file set, which also means a parent work. I believe we always want this to be # valid, because we want to leverage the locator/applicator behavior instead of the # implicit work. true end |