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
26 27 28 29 |
# File 'app/models/qa/subject_mesh_term.rb', line 26 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 = read_attribute(:synonyms) s.nil? ? [] : s.split("|") end |
#synonyms=(syn_list) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/models/qa/subject_mesh_term.rb', line 17 def synonyms=(syn_list) write_attribute(:synonyms, if syn_list.respond_to?(:join) syn_list.join('|') else syn_list end) end |