Class: Hyrax::CustomQueries::Navigators::FindFiles
- Inherits:
-
Object
- Object
- Hyrax::CustomQueries::Navigators::FindFiles
- Defined in:
- app/services/hyrax/custom_queries/navigators/find_files.rb
Overview
Instance Attribute Summary collapse
- #query_service ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#find_extracted_text(file_set:) ⇒ Hyrax::FileMetadata
Find extracted text id of a given file set resource, and map to file metadata resource.
-
#find_files(file_set:) ⇒ Array<Hyrax::FileMetadata>
Find file ids of a given file set resource, and map to file metadata resources.
-
#find_original_file(file_set:) ⇒ Hyrax::FileMetadata
Find original file id of a given file set resource, and map to file metadata resource.
-
#find_thumbnail(file_set:) ⇒ Hyrax::FileMetadata
Find thumbnail id of a given file set resource, and map to file metadata resource.
-
#initialize(query_service:) ⇒ FindFiles
constructor
A new instance of FindFiles.
Constructor Details
#initialize(query_service:) ⇒ FindFiles
Returns a new instance of FindFiles.
22 23 24 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 22 def initialize(query_service:) @query_service = query_service end |
Instance Attribute Details
#query_service ⇒ Object (readonly)
26 27 28 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 26 def query_service @query_service end |
Class Method Details
.queries ⇒ Object
15 16 17 18 19 20 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 15 def self.queries [:find_files, :find_original_file, :find_extracted_text, :find_thumbnail] end |
Instance Method Details
#find_extracted_text(file_set:) ⇒ Hyrax::FileMetadata
Find extracted text id of a given file set resource, and map to file metadata resource
55 56 57 58 59 60 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 55 def find_extracted_text(file_set:) find_exactly_one_file_by_use( file_set: file_set, use: Hyrax::FileMetadata::Use::EXTRACTED_TEXT ) end |
#find_files(file_set:) ⇒ Array<Hyrax::FileMetadata>
Find file ids of a given file set resource, and map to file metadata resources
32 33 34 35 36 37 38 39 40 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 32 def find_files(file_set:) if file_set.respond_to?(:file_ids) return [] if file_set.file_ids.blank? query_service.custom_queries.(ids: file_set.file_ids) else raise ::Valkyrie::Persistence::ObjectNotFoundError, "#{file_set.internal_resource} is not a `Hydra::FileSet` implementer" end end |
#find_original_file(file_set:) ⇒ Hyrax::FileMetadata
Find original file id of a given file set resource, and map to file metadata resource
45 46 47 48 49 50 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 45 def find_original_file(file_set:) find_exactly_one_file_by_use( file_set: file_set, use: Hyrax::FileMetadata::Use::ORIGINAL_FILE ) end |
#find_thumbnail(file_set:) ⇒ Hyrax::FileMetadata
Find thumbnail id of a given file set resource, and map to file metadata resource
65 66 67 68 69 70 |
# File 'app/services/hyrax/custom_queries/navigators/find_files.rb', line 65 def find_thumbnail(file_set:) find_exactly_one_file_by_use( file_set: file_set, use: Hyrax::FileMetadata::Use::THUMBNAIL_IMAGE ) end |