Class: TaxonomyTerm
- Inherits:
-
Object
- Object
- TaxonomyTerm
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/taxonomy_term.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.label_for_term(term_id) ⇒ Object
28 29 30 |
# File 'app/models/taxonomy_term.rb', line 28 def self.label_for_term(term_id) where(term_id: term_id).try(:first).try(:label) if term_id end |
.purge! ⇒ Object
24 25 26 |
# File 'app/models/taxonomy_term.rb', line 24 def self.purge! TaxonomyTerm.destroy_all end |
Instance Method Details
#ancestor?(term) ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'app/models/taxonomy_term.rb', line 36 def ancestor?(term) if(parent_term) (parent_term == term) or parent_term.ancestor?(term) else false end end |
#descendant?(term) ⇒ Boolean
44 45 46 47 48 49 |
# File 'app/models/taxonomy_term.rb', line 44 def descendant?(term) # accept either an ID string or a term term_id = term.is_a?(String) ? term : term.try(:term_id) # loop thru child terms and look for the id child_term_ids.index(term_id) or child_terms.detect {|c| c.descendant? term_id } end |
#fund_code ⇒ Object
32 33 34 |
# File 'app/models/taxonomy_term.rb', line 32 def fund_code term_type['FUND_CODE'] end |