Class: QaServer::AuthorityLoaderService

Inherits:
Object
  • Object
show all
Defined in:
app/services/qa_server/authority_loader_service.rb

Class Method Summary collapse

Class Method Details

.load(authority_name:, status_log: nil) ⇒ Qa::Authorities::LinkedData::GenericAuthority

Load a QA authority

Parameters:

  • authority_name (String)

    name of the authority to load (e.g. “agrovoc_direct”)

  • status_log (ScenarioLogger) (defaults to: nil)

    logger to hold failure information if the authority cannot be loaded

Returns:

  • (Qa::Authorities::LinkedData::GenericAuthority)

    the instance of the authority that can receive QA requests OR nil if fails to load



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/qa_server/authority_loader_service.rb', line 10

def load(authority_name:, status_log: nil)
  begin
    authority = load_authority(authority_name, status_log)
    return nil if authority.blank?
  rescue Exception => e
    if status_log.present?
      status_log.add(authority_name: authority_name,
                     status: QaServer::ScenarioValidator::FAIL,
                     error_message: "Unable to load authority '#{authority_name}'; cause: #{e.message}")
    end
    return nil
  end
  authority
end