Class: Specify::Model::GeographicName

Inherits:
Object
  • Object
show all
Defined in:
lib/specify/models/geography/geographic_name.rb

Overview

Sequel::Model for geographic names (countries, states, counties)

Instance Method Summary collapse

Instance Method Details

#before_createObject

create: rank.add_taxon or parent.add_child



18
19
20
21
22
23
24
25
# File 'lib/specify/models/geography/geographic_name.rb', line 18

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

#before_updateObject



27
28
29
30
31
# File 'lib/specify/models/geography/geographic_name.rb', line 27

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

#children?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/specify/models/geography/geographic_name.rb', line 37

def children?
  !children.empty?
end

#inspectObject



33
34
35
# File 'lib/specify/models/geography/geographic_name.rb', line 33

def inspect
  "id: #{self.GeographyID}; Full Name: '#{self.FullName}'"
end