Class: Specify::Model::CollectionObject

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

Overview

A Sequel::Model representing collection objects

Instance Method Summary collapse

Instance Method Details

#auto_numberObject


48
49
50
# File 'lib/specify/models/collection_object.rb', line 48

def auto_number
  self.CatalogNumber || collection.auto_numbering_scheme.increment
end

#before_createObject


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/specify/models/collection_object.rb', line 26

def before_create
  self.Version = 0
  self.TimestampCreated = Time.now
  self.collection_member = collection
  self.CatalogNumber = auto_number
  self.CatalogedDate = Date.today
  self.CatalogedDatePrecision = 1
  self.GUID = SecureRandom.uuid
  self.collecting_event = embed_collecting_event
  super
end

#before_updateObject


38
39
40
41
42
# File 'lib/specify/models/collection_object.rb', line 38

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

#catalog_numberObject


52
53
54
# File 'lib/specify/models/collection_object.rb', line 52

def catalog_number
  self.CatalogNumber
end

#cataloged_dateObject


56
57
58
# File 'lib/specify/models/collection_object.rb', line 56

def cataloged_date
  self.CatalogedDate
end

#embed_collecting_eventObject


60
61
62
63
# File 'lib/specify/models/collection_object.rb', line 60

def embed_collecting_event
  return unless collection.IsEmbeddedCollectingEvent
  CollectingEvent.create discipline: collection.discipline
end

#geo_locate(collecting_information) ⇒ Object

collecting_information: Hash


66
67
68
69
# File 'lib/specify/models/collection_object.rb', line 66

def geo_locate(collecting_information)
  collecting_event.update(collecting_information)
  collecting_event.save
end

#identify(determination_information) ⇒ Object

determination_information: Hash


72
73
74
75
# File 'lib/specify/models/collection_object.rb', line 72

def identify(determination_information)
  add_determination determination_information
  self.save
end

#to_sObject


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

def to_s
  "#{catalog_number} cataloged by #{cataloger}, #{cataloged_date}"
end