Module: Bulkrax::FileSetEntryBehavior
- Included in:
- CsvFileSetEntry, RdfFileSetEntry
- Defined in:
- app/models/concerns/bulkrax/file_set_entry_behavior.rb
Instance Method Summary collapse
- #add_path_to_file ⇒ Object
- #child_jobs ⇒ Object
- #factory_class ⇒ Object
- #parent_jobs ⇒ Object
- #validate_presence_of_filename! ⇒ Object
- #validate_presence_of_parent! ⇒ Object
Instance Method Details
#add_path_to_file ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/concerns/bulkrax/file_set_entry_behavior.rb', line 9 def add_path_to_file ['file'].each_with_index do |filename, i| next if filename.blank? path_to_file = parser.path_to_files(filename: filename) ['file'][i] = path_to_file end ['file'].delete('') raise ::StandardError, "one or more file paths are invalid: #{parsed_metadata['file'].join(', ')}" unless ['file'].map { |file_path| ::File.file?(file_path) }.all? ['file'] end |
#child_jobs ⇒ Object
40 41 42 |
# File 'app/models/concerns/bulkrax/file_set_entry_behavior.rb', line 40 def child_jobs raise ::StandardError, 'A FileSet cannot be a parent of a Collection, Work, or other FileSet' end |
#factory_class ⇒ Object
5 6 7 |
# File 'app/models/concerns/bulkrax/file_set_entry_behavior.rb', line 5 def factory_class ::FileSet end |
#parent_jobs ⇒ Object
36 37 38 |
# File 'app/models/concerns/bulkrax/file_set_entry_behavior.rb', line 36 def parent_jobs false # FileSet relationships are handled in ObjectFactory#create_file_set end |
#validate_presence_of_filename! ⇒ Object
24 25 26 27 28 |
# File 'app/models/concerns/bulkrax/file_set_entry_behavior.rb', line 24 def validate_presence_of_filename! return if &.[]('file')&.map(&:present?)&.any? raise StandardError, 'File set must have a filename' end |
#validate_presence_of_parent! ⇒ Object
30 31 32 33 34 |
# File 'app/models/concerns/bulkrax/file_set_entry_behavior.rb', line 30 def validate_presence_of_parent! return if []&.map(&:present?)&.any? raise StandardError, 'File set must be related to at least one work' end |