Class: Samvera::Derivatives::Hyrax::FileSetDerivativesServiceWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/samvera/derivatives/hyrax.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_set:, file_path:) ⇒ FileSetDerivativesServiceWrapper

Returns a new instance of FileSetDerivativesServiceWrapper.

Parameters:

  • file_set (FileSet)
  • file_path (String)


83
84
85
86
87
# File 'lib/samvera/derivatives/hyrax.rb', line 83

def initialize(file_set:, file_path:)
  @file_set = file_set
  @file_path = file_path
  @wrapped_derivative_service = wrapped_derivative_service_class.new(file_set)
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



88
89
90
# File 'lib/samvera/derivatives/hyrax.rb', line 88

def file_path
  @file_path
end

#file_setObject (readonly)

Returns the value of attribute file_set.



88
89
90
# File 'lib/samvera/derivatives/hyrax.rb', line 88

def file_set
  @file_set
end

#wrapped_derivative_serviceObject (readonly)

Returns the value of attribute wrapped_derivative_service.



88
89
90
# File 'lib/samvera/derivatives/hyrax.rb', line 88

def wrapped_derivative_service
  @wrapped_derivative_service
end

Instance Method Details

#apply!Object



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/samvera/derivatives/hyrax.rb', line 96

def apply!(*)
  # Why the short-circuit? By the nature of the underlying
  # ::Hyrax::FileSetDerivativesService, we generate multiple derivatives in one pass.  But
  # with the implementation of Samvera::Derivatives, we declare the derivatives and then
  # iterate on locating and applying them.  With this short-circuit, we will only apply the
  # derivatives once.
  return true if defined?(@already_applied)

  return false unless wrapped_derivative_service.valid?

  wrapped_derivative_service.create_derivatives(file_path)
  @already_applied = true
end

#present?Boolean

Returns:

  • (Boolean)

See Also:



91
92
93
# File 'lib/samvera/derivatives/hyrax.rb', line 91

def present?
  true
end