Class: Hyrax::TolerantSelectService

Inherits:
QaSelectService show all
Defined in:
app/services/hyrax/tolerant_select_service.rb

Overview

A more tolerant QaSelectService. This service treats terms with no active: property as active terms, instead of erroring with eKeyError.

Direct Known Subclasses

LicenseService, RightsStatementService

Instance Attribute Summary

Attributes inherited from QaSelectService

#authority

Instance Method Summary collapse

Methods inherited from QaSelectService

#include_current_value, #initialize, #label, #select_active_options, #select_all_options

Constructor Details

This class inherits a constructor from Hyrax::QaSelectService

Instance Method Details

#active?(id) ⇒ Boolean

Returns indicates whether the term is active; false if the term is inactive or is not present in the authority; defaults to true when the term is present but no active: key is given.

Returns:

  • (Boolean)

    indicates whether the term is active; false if the term is inactive or is not present in the authority; defaults to true when the term is present but no active: key is given.



11
12
13
14
15
# File 'app/services/hyrax/tolerant_select_service.rb', line 11

def active?(id)
  result = authority.find(id)
  return false if result.blank?
  result.fetch('active', true)
end

#active_elementsEnumerable<Hash>

Returns:

  • (Enumerable<Hash>)

Raises:

  • (KeyError)

    when no 'term' value is present for the id



21
22
23
# File 'app/services/hyrax/tolerant_select_service.rb', line 21

def active_elements
  authority.all.select { |e| e.fetch('active', true) }
end