Class: Combination

Inherits:
TaxonName
  • Object
show all
Includes:
Housekeeping
Defined in:
app/models/combination.rb

Instance Method Summary collapse

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from TaxonName

#all_generic_placements, #all_taxon_name_relationships, #ancestor_at_rank, #cached_name_and_author_year, #gender_class, #gender_name, #get_author_and_year, #get_cached_misspelling, #get_classified_as, #get_combination, #get_full_name, #get_genus_species, #get_higher_classification, #get_original_combination, #get_valid_taxon_name, #name_in_gender, #name_with_alternative_spelling, #name_with_misspelling, #nomenclature_date, #part_of_speech_class, #part_of_speech_name, #rank, #rank_class, #rank_class=, #rank_string, #related_taxon_names, #set_cached_author_year, #set_cached_classified_as, #set_cached_full_name, #set_cached_higher_classification, #set_cached_misspelling, #set_cached_names, #set_cached_original_combination, #set_primary_homonym_alt, #set_primaty_homonym, #set_secondary_homonym, #set_secondary_homonym_alt, #set_type_if_empty, #unavailable?, #unavailable_or_invalid?

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Instance Method Details

#sv_combination_duplicatesObject



60
61
62
63
# File 'app/models/combination.rb', line 60

def sv_combination_duplicates
  duplicate = Combination.not_self(self.id).with_parent_id(self.parent_id).with_cached_original_combination(self.cached_original_combination)
  soft_validations.add(:base, 'Combination is a duplicate') unless duplicate.empty?
end

#sv_source_older_then_descriptionObject

region Soft validation



49
50
51
52
53
54
55
56
57
58
# File 'app/models/combination.rb', line 49

def sv_source_older_then_description
  date1 = self.nomenclature_date
  date2  = !!self.parent_id ? self.parent.nomenclature_date : nil
  if !!date1 && !!date2
    soft_validations.add(:year_of_publication, 'The combination is older than the taxon') if date2 - date1 > 0
  end
  if !!self.source && !!self.year_of_publication
    soft_validations.add(:source_id, 'The year of publication and the year of source do not match') if self.source.year != self.year_of_publication
  end
end