Class: Hyrax::FileSetTypeService

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

Overview

Note:

this service is for ‘Hyrax::FileSet` Valkyrie Resources. for ActiveFedora file sets see Hydra::Works::MimeTypes

Resolves file sets to a mime type. Provides a series of utility methods for figuring out what a file set is all about.

Constant Summary collapse

DEFAULT_AUDIO_TYPES =
['audio/mp3', 'audio/mpeg', 'audio/wav',
'audio/x-wave', 'audio/x-wav', 'audio/ogg'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_set:, characterization_proxy: Hyrax.config.characterization_proxy, query_service: Hyrax.custom_queries) ⇒ FileSetTypeService

Returns a new instance of FileSetTypeService.

Parameters:

  • file_set (Hyrax::FileSet)
  • characterization_proxy (Symbol) (defaults to: Hyrax.config.characterization_proxy)

    defaults to the setting provided by the application’s ActiveFedora ‘FileSet` class.



23
24
25
26
27
# File 'app/services/hyrax/file_set_type_service.rb', line 23

def initialize(file_set:, characterization_proxy: Hyrax.config.characterization_proxy, query_service: Hyrax.custom_queries)
  @file_set = file_set
  @proxy_use = Hyrax::FileMetadata::Use.uri_for(use: characterization_proxy)
  @queries = query_service
end

Instance Attribute Details

#file_setObject (readonly)

Returns the value of attribute file_set.



17
18
19
# File 'app/services/hyrax/file_set_type_service.rb', line 17

def file_set
  @file_set
end

Instance Method Details

#audio?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/services/hyrax/file_set_type_service.rb', line 41

def audio?
  audio_types.include?(mime_type)
end

#metadataObject



29
30
31
# File 'app/services/hyrax/file_set_type_service.rb', line 29

def 
  @metadata ||= @queries.(resource: file_set, use: @proxy_use).first
end

#mime_typeString

Returns:

  • (String)


35
36
37
# File 'app/services/hyrax/file_set_type_service.rb', line 35

def mime_type
  &.mime_type || Hyrax::FileMetadata::GENERIC_MIME_TYPE
end