Class: RecordLoader::RequestTypeLoader

Inherits:
ApplicationRecordLoader show all
Defined in:
lib/record_loader/request_type_loader.rb

Overview

Creates the specified request types if they are not present

Instance Method Summary collapse

Methods inherited from ApplicationRecordLoader

#wip_list

Instance Method Details

#create_or_update!(key, options) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/record_loader/request_type_loader.rb', line 12

def create_or_update!(key, options)
  request_type = create_or_update_request_type(key, options)
  add_library_types(request_type, options.fetch('library_types', []))
  add_acceptable_purposes(request_type, options.fetch('acceptable_purposes', []))
  request_type
rescue StandardError => e
  raise StandardError, "Failed to create #{key} due to: #{e.message}"
end