Class: Hyrax::QaSelectService
- Inherits:
-
Object
- Object
- Hyrax::QaSelectService
- Defined in:
- app/services/hyrax/qa_select_service.rb
Overview
This is an abstract class to provide select options from a questioning authority backed authority
Direct Known Subclasses
Instance Attribute Summary collapse
-
#authority ⇒ Object
readonly
Returns the value of attribute authority.
Instance Method Summary collapse
- #active?(id) ⇒ Boolean
- #active_elements ⇒ Object
-
#initialize(authority_name) ⇒ QaSelectService
constructor
A new instance of QaSelectService.
-
#label(id) { ... } ⇒ String
The label for the authority.
- #select_active_options ⇒ Object
- #select_all_options ⇒ Object
Constructor Details
#initialize(authority_name) ⇒ QaSelectService
Returns a new instance of QaSelectService.
7 8 9 |
# File 'app/services/hyrax/qa_select_service.rb', line 7 def initialize() @authority = Qa::Authorities::Local.() end |
Instance Attribute Details
#authority ⇒ Object (readonly)
Returns the value of attribute authority.
5 6 7 |
# File 'app/services/hyrax/qa_select_service.rb', line 5 def @authority end |
Instance Method Details
#active?(id) ⇒ Boolean
21 22 23 |
# File 'app/services/hyrax/qa_select_service.rb', line 21 def active?(id) .find(id).fetch('active') end |
#active_elements ⇒ Object
38 39 40 |
# File 'app/services/hyrax/qa_select_service.rb', line 38 def active_elements .all.select { |e| e.fetch('active') } end |
#label(id) { ... } ⇒ String
Returns the label for the authority.
34 35 36 |
# File 'app/services/hyrax/qa_select_service.rb', line 34 def label(id, &block) .find(id).fetch('term', &block) end |
#select_active_options ⇒ Object
17 18 19 |
# File 'app/services/hyrax/qa_select_service.rb', line 17 def active_elements.map { |e| [e[:label], e[:id]] } end |
#select_all_options ⇒ Object
11 12 13 14 15 |
# File 'app/services/hyrax/qa_select_service.rb', line 11 def .all.map do |element| [element[:label], element[:id]] end end |