Class: Qa::SubjectMeshTerm
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Qa::SubjectMeshTerm
- Defined in:
- app/models/qa/subject_mesh_term.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_tree_number(tree_id) ⇒ Object
4 5 6 |
# File 'app/models/qa/subject_mesh_term.rb', line 4 def self.from_tree_number(tree_id) Qa::SubjectMeshTerm.joins('INNER JOIN qa_mesh_trees ON qa_subject_mesh_terms.term_id = qa_mesh_trees.term_id').where('qa_mesh_trees.tree_number = ?', tree_id) end |
Instance Method Details
#parents ⇒ Object
21 22 23 24 |
# File 'app/models/qa/subject_mesh_term.rb', line 21 def parents t = trees t.map { |tn| initial_segements_of(tn) }.flatten.uniq.map { |tn| Qa::SubjectMeshTerm.from_tree_number(tn) } end |
#synonyms ⇒ Object
12 13 14 15 |
# File 'app/models/qa/subject_mesh_term.rb', line 12 def synonyms s = self[:synonyms] s.nil? ? [] : s.split("|") end |
#synonyms=(syn_list) ⇒ Object
17 18 19 |
# File 'app/models/qa/subject_mesh_term.rb', line 17 def synonyms=(syn_list) self[:synonyms] = syn_list.respond_to?(:join) ? syn_list.join('|') : syn_list end |