Class: Specify::Model::Determination

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

Overview

Determinations are opinions on what Specify::Model::Taxon a Specify::Model::CollectionObject represents.

A Determination belongs to a Specify::Model::CollectionObject (collection_object).

A Specify::Model::CollectionObject can have multiple determinations, only one of which can be the current determination.

A Determination can belong to a Specify::Model::Taxon. If that taxon is a synonym of another taxon, the Determination will also belong to the accepted Taxon as the preferred_taxon.

Instance Method Summary collapse

Methods included from Updateable

#before_update

Instance Method Details

#before_createObject

Sequel hook that assigns a GUID. Sets the collection to the Specify::Model::Collection that the collection_object of self belongs to.

Sets the preferred_taxon to the Specify::Model::Taxon#accepted_name if it has one, the Specify::Model::Taxon itself otherwise.

Sets the IsCurrent status to true.



48
49
50
51
52
53
54
# File 'lib/specify/models/determination.rb', line 48

def before_create
  self[:GUID] = SecureRandom.uuid
  self.collection = collection_object&.collection
  self.preferred_taxon = taxon.accepted_name || taxon
  self[:IsCurrent] = true
  super
end

#current?Boolean

Returns true if self is the current determination for #collection_object

Returns:

  • (Boolean)


58
59
60
# File 'lib/specify/models/determination.rb', line 58

def current?
  self[:IsCurrent]
end