Class: CurationConcerns::QaSelectService
- Inherits:
-
Object
- Object
- CurationConcerns::QaSelectService
show all
- Defined in:
- app/services/curation_concerns/qa_select_service.rb
Overview
This is an abstract class to provide select options from a questioning authority backed authority
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of QaSelectService.
7
8
9
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 7
def initialize(authority_name)
@authority = Qa::Authorities::Local.subauthority_for(authority_name)
end
|
Instance Attribute Details
#authority ⇒ Object
Returns the value of attribute authority.
5
6
7
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 5
def authority
@authority
end
|
Instance Method Details
#active?(id) ⇒ Boolean
21
22
23
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 21
def active?(id)
authority.find(id).fetch('active')
end
|
#active_elements ⇒ Object
29
30
31
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 29
def active_elements
authority.all.select { |e| active?(e.fetch('id')) }
end
|
#label(id) ⇒ Object
25
26
27
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 25
def label(id)
authority.find(id).fetch('term')
end
|
#select_active_options ⇒ Object
17
18
19
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 17
def select_active_options
active_elements.map { |e| [e[:label], e[:id]] }
end
|
#select_all_options ⇒ Object
11
12
13
14
15
|
# File 'app/services/curation_concerns/qa_select_service.rb', line 11
def select_all_options
authority.all.map do |element|
[element[:label], element[:id]]
end
end
|