Class: Hyrax::DerivativeService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/derivative_service.rb

Overview

A factory class and interface defining class that finds the first valid registered service for the given object.

The .for method is the factory. The instance_methods of this class defines the interface.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_set) ⇒ DerivativeService

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DerivativeService.



40
41
42
# File 'app/services/hyrax/derivative_service.rb', line 40

def initialize(file_set)
  @file_set = file_set
end

Instance Attribute Details

#file_setObject (readonly)



36
37
38
# File 'app/services/hyrax/derivative_service.rb', line 36

def file_set
  @file_set
end

Class Method Details

.for(file_set, services: Hyrax.config.derivative_services) ⇒ #cleanup_derivatives, ...

Get the first valid registered service for the given file_set.

Parameters:

Returns:



32
33
34
35
# File 'app/services/hyrax/derivative_service.rb', line 32

def self.for(file_set, services: Hyrax.config.derivative_services)
  services.map { |service| service.new(file_set) }.find(&:valid?) ||
    new(file_set)
end

.servicesObject

Deprecated.

favor Hyrax.config.derivative_services



21
22
23
24
# File 'app/services/hyrax/derivative_service.rb', line 21

def self.services
  Deprecation.warn("Hyrax::DerivativeService.services is deprecated; favor Hyrax.config.derivative_servies")
  Hyrax.config.derivative_services
end

.services=(services) ⇒ Object

Deprecated.

favor Hyrax.config.derivative_services=



15
16
17
18
# File 'app/services/hyrax/derivative_service.rb', line 15

def self.services=(services)
  Deprecation.warn("Hyrax::DerivativeService.services= is deprecated; favor Hyrax.config.derivative_servies=")
  Hyrax.config.derivative_services = Array(services)
end

Instance Method Details

#cleanup_derivativesObject



45
# File 'app/services/hyrax/derivative_service.rb', line 45

def cleanup_derivatives; end

#create_derivatives(_file_path) ⇒ Object



48
# File 'app/services/hyrax/derivative_service.rb', line 48

def create_derivatives(_file_path); end

#derivative_url(_destination_name) ⇒ Object

Note:

What should this return?



52
53
54
# File 'app/services/hyrax/derivative_service.rb', line 52

def derivative_url(_destination_name)
  ""
end

#valid?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/services/hyrax/derivative_service.rb', line 57

def valid?
  true
end