Class: Qa::Authorities::Mesh
- Inherits:
-
Object
- Object
- Qa::Authorities::Mesh
- Defined in:
- lib/qa/authorities/mesh.rb
Instance Method Summary collapse
- #get_full_record(id) ⇒ Object
-
#parse_authority_response ⇒ Object
satisfy TermsController.
- #results ⇒ Object
- #search(q, sub_authority = nil) ⇒ Object
Instance Method Details
#get_full_record(id) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/qa/authorities/mesh.rb', line 15 def get_full_record(id) @results ||= begin r = Qa::SubjectMeshTerm.where(term_id: id).limit(1).first r.nil? ? nil : {id: r.term_id, label: r.term, synonyms: r.synonyms} end end |
#parse_authority_response ⇒ Object
satisfy TermsController
23 24 |
# File 'lib/qa/authorities/mesh.rb', line 23 def end |
#results ⇒ Object
4 5 6 7 8 9 |
# File 'lib/qa/authorities/mesh.rb', line 4 def results @results ||= begin r = Qa::SubjectMeshTerm.where('term_lower LIKE ?', "#{@q}%").limit(10) r.map { |t| {id: t.term_id, label: t.term} } end end |
#search(q, sub_authority = nil) ⇒ Object
11 12 13 |
# File 'lib/qa/authorities/mesh.rb', line 11 def search(q, =nil) @q = q end |