Class: Specify::Model::Taxon

Inherits:
Object
  • Object
show all
Includes:
Createable, Updateable
Defined in:
lib/specify/models/taxonomy/taxon.rb

Overview

Taxon is the item class for the Specify::Model::Taxonomy tree. A Taxon holds information about the items to be classified, i.e. concepts of taxonomic names. Each Taxon belongs to a Specify::Model::Rank, that represents its formal Linnean classification rank.

A Taxon has a parent (another instance of Taxon) unless it is the root taxon of the tree and can have children (other instances of Taxon).

Instance Method Summary collapse

Methods included from Updateable

#before_update

Instance Method Details

#before_createObject

Assigns new instances that are created from a Specify::Model::Rank to the rank’s Specify::Model::Taxonomy. Assigns a GUID for the record.



37
38
39
40
41
# File 'lib/specify/models/taxonomy/taxon.rb', line 37

def before_create
  self.taxonomy = rank&.taxonomy || parent.rank&.taxonomy
  self[:GUID] = SecureRandom.uuid
  super
end

#children?Boolean

Returns true if self has children.

Returns:

  • (Boolean)


44
45
46
# File 'lib/specify/models/taxonomy/taxon.rb', line 44

def children?
  !children.empty?
end

#nameObject

Returns a String with the taxon name.



49
50
51
# File 'lib/specify/models/taxonomy/taxon.rb', line 49

def name
  self[:Name]
end