Class: Hyrax::TolerantSelectService
- Inherits:
-
QaSelectService
- Object
- QaSelectService
- Hyrax::TolerantSelectService
- 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`.
Instance Attribute Summary
Attributes inherited from QaSelectService
Instance Method Summary collapse
-
#active?(id) ⇒ Boolean
Indicates whether the term is active; false if the term is inactive or does not exist; defaults to true when no key is given.
- #active_elements ⇒ Enumerable<Hash>
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 does not exist; defaults to true when no key is given.
11 12 13 |
# File 'app/services/hyrax/tolerant_select_service.rb', line 11 def active?(id) .find(id)&.fetch('active', true) end |
#active_elements ⇒ Enumerable<Hash>
19 20 21 |
# File 'app/services/hyrax/tolerant_select_service.rb', line 19 def active_elements .all.select { |e| e.fetch('active', true) } end |