Class: TaxonNameClassification::Latinized::Gender
Defined Under Namespace
Classes: Feminine, Masculine, Neuter
Constant Summary
collapse
- NOMEN_URI =
'http://purl.obolibrary.org/obo/NOMEN_0000045'.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
assignable
Class Method Details
.applicable_ranks ⇒ Object
7
8
9
|
# File 'app/models/taxon_name_classification/latinized/gender.rb', line 7
def self.applicable_ranks
GENUS_RANK_NAMES
end
|
Instance Method Details
#set_cached_names_for_taxon_names ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/models/taxon_name_classification/latinized/gender.rb', line 27
def set_cached_names_for_taxon_names
t = taxon_name
return if t.destroyed?
t.update_columns(cached_gender: destroyed? ? nil : classification_label.downcase)
t.descendants.unscope(:order).with_same_cached_valid_id.each do |t1|
n = t1.get_full_name
t1.update_columns(
cached: n,
cached_html: t1.get_full_name_html(n),
)
end
TaxonNameRelationship::OriginalCombination.where(subject_taxon_name: t).collect{|i| i.object_taxon_name}.uniq.each do |t1|
t1.update_cached_original_combinations
end
TaxonNameRelationship::Combination.where(subject_taxon_name: t).collect{|i| i.object_taxon_name}.uniq.each do |t1|
next if t1.verbatim_name.present?
fresh_name = t1.get_full_name next if fresh_name == t1.cached
t1.update_column(:verbatim_name, t1.cached)
end
end
|
#validate_applicable_rank ⇒ Object
19
20
21
22
23
24
25
|
# File 'app/models/taxon_name_classification/latinized/gender.rb', line 19
def validate_applicable_rank
return true if taxon_name.nil?
unless self.class.applicable_ranks.include?(taxon_name.rank_string)
errors.add(:taxon_name, 'Gender is only applicable to genus names')
end
end
|
#validate_uniqueness_of_latinized ⇒ Object
11
12
13
14
15
|
# File 'app/models/taxon_name_classification/latinized/gender.rb', line 11
def validate_uniqueness_of_latinized
if TaxonNameClassification::Latinized::Gender.where(taxon_name_id: self.taxon_name_id).not_self(self).any?
errors.add(:taxon_name_id, 'The Gender is already selected')
end
end
|