Class: RecordLoader::RequestTypeLoader
- Inherits:
-
ApplicationRecordLoader
- Object
- Base
- ApplicationRecordLoader
- RecordLoader::RequestTypeLoader
- 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
Instance Method Details
#create_or_update!(key, options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/record_loader/request_type_loader.rb', line 12 def create_or_update!(key, ) RequestType .create_with(()) .find_or_create_by!(key:) .tap do |request_type| add_library_types(request_type, .fetch('library_types', [])) add_acceptable_purposes(request_type, .fetch('acceptable_purposes', [])) end rescue StandardError => e raise StandardError, "Failed to create #{key} due to: #{e.}" end |