Class: Specify::Model::Taxon

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

Overview

Sequel::Model for taxa

Instance Method Summary collapse

Instance Method Details

#before_createObject

create: rank.add_taxon or parent.add_child


16
17
18
19
20
21
22
# File 'lib/specify/models/taxonomy/taxon.rb', line 16

def before_create
  self.taxonomy = rank&.taxonomy || parent.rank&.taxonomy
  self.Version = 0
  self.TimestampCreated = Time.now
  self.GUID = SecureRandom.uuid
  super
end

#before_updateObject


24
25
26
27
28
# File 'lib/specify/models/taxonomy/taxon.rb', line 24

def before_update
  self.Version += 1
  self.TimestampModified = Time.now
  super
end

#children?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/specify/models/taxonomy/taxon.rb', line 30

def children?
  !children.empty?
end