Class: Qa::Authorities::Mesh
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#all ⇒ Object
18 19 20 21 22 23 |
# File 'lib/qa/authorities/mesh.rb', line 18 def all begin r = Qa::SubjectMeshTerm.all r.map { |t| {id: t.term_id, label: t.term} } end end |
#find(id) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/qa/authorities/mesh.rb', line 11 def find id 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 |
#search(q) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/qa/authorities/mesh.rb', line 4 def search q begin r = Qa::SubjectMeshTerm.where('term_lower LIKE ?', "#{q}%").limit(10) r.map { |t| {id: t.term_id, label: t.term} } end end |