Class: Specify::Model::CollectionObject
- Inherits:
-
Object
- Object
- Specify::Model::CollectionObject
- Includes:
- Createable, Updateable
- Defined in:
- lib/specify/models/collection_object.rb
Overview
CollectionObjects represent the organisms or artifeacts collected, but not the physical items stored in a collection (see Specify::Model::Preparation).
A CollectionObject belongs to Specify::Model::Collection and can have one or many #preparations (instances of Specify::Model::Preparation).
A CollectionObject belongs to a #collecting_event (an instance of Specify::Model::CollectingEvent), that holds information about when, where, how, and by whom it was collected.
A CollectionObject can have one or many #determinations (instances of Specify::Model::Determination), which represent opinions on what Specify::Model::Taxon the CollectionObject represents.
Instance Method Summary collapse
-
#auto_number ⇒ Object
Returns the #catalog_number of
selfif it has one. -
#before_create ⇒ Object
Sequel hook that assigns a newly created records to a Specify::Model::Collection (the collection is referenced twice; through #collection and #collection_member; the #collection will be automatically set if the records is created through the Specify::Model::Collecion#add_collection_object association method; the hook will set the other reference).
-
#catalog_number ⇒ Object
Returns a String that is the catalog number of
self. -
#cataloged_date ⇒ Object
Returns a Date that is the date
selfwas cataloged (typically when it was registered in the database). -
#embed_collecting_event ⇒ Object
If CollectionObjects in #collection can not share colecting events (there is one Specify::Model::CollectingEvent for every CollectionObject), this will create a new, empty, Specify::Model::CollectingEvent for the record.
-
#geo_locate(vals) ⇒ Object
Updates the associated Specify::Model::CollectingEvent with
vals(a Hash). -
#identify(vals) ⇒ Object
Creates a new Specify::Model::Determination for
selfwithvals(a Hash). -
#inspect ⇒ Object
Creates a string representation of
self. -
#to_s ⇒ Object
Creates a string representation of
self.
Methods included from Updateable
Instance Method Details
#auto_number ⇒ Object
Returns the #catalog_number of self if it has one. If not, returns the next available catalog number in the Specify::Model::AutoNumberingScheme in the Specify::Model::Collection self belongs to.
50 51 52 |
# File 'lib/specify/models/collection_object.rb', line 50 def auto_number catalog_number || collection.auto_numbering_scheme.increment end |
#before_create ⇒ Object
Sequel hook that assigns a newly created records to a Specify::Model::Collection (the collection is referenced twice; through #collection and #collection_member; the #collection will be automatically set if the records is created through the Specify::Model::Collecion#add_collection_object association method; the hook will set the other reference).
Assigns the next available #catalog_number in the collection.
Sets the CatalogedDate attribute and assigns a Specify::Model::Agent as the #cataloger.
Assigns a GUID.
If CollectionObjects in #collection can not share colecting events (there is one Specify::Model::CollectingEvent for every CollectionObject), this will create a new, empty, Specify::Model::CollectingEvent for the record.
72 73 74 75 76 77 78 79 80 |
# File 'lib/specify/models/collection_object.rb', line 72 def before_create self.collection_member = collection self[:CatalogNumber] = auto_number self[:CatalogedDate] = Date.today self[:CatalogedDatePrecision] = 1 self[:GUID] = SecureRandom.uuid self.collecting_event = super end |
#catalog_number ⇒ Object
Returns a String that is the catalog number of self.
83 84 85 |
# File 'lib/specify/models/collection_object.rb', line 83 def catalog_number self[:CatalogNumber] end |
#cataloged_date ⇒ Object
Returns a Date that is the date self was cataloged (typically when it was registered in the database).
89 90 91 |
# File 'lib/specify/models/collection_object.rb', line 89 def cataloged_date self[:CatalogedDate] end |
#embed_collecting_event ⇒ Object
If CollectionObjects in #collection can not share colecting events (there is one Specify::Model::CollectingEvent for every CollectionObject), this will create a new, empty, Specify::Model::CollectingEvent for the record.
97 98 99 100 |
# File 'lib/specify/models/collection_object.rb', line 97 def return unless collection. CollectingEvent.create discipline: collection.discipline end |
#geo_locate(vals) ⇒ Object
Updates the associated Specify::Model::CollectingEvent with vals (a Hash).
104 105 106 107 |
# File 'lib/specify/models/collection_object.rb', line 104 def geo_locate(vals) collecting_event.update(vals) collecting_event.save end |
#identify(vals) ⇒ Object
Creates a new Specify::Model::Determination for self with vals (a Hash).
111 112 113 114 |
# File 'lib/specify/models/collection_object.rb', line 111 def identify(vals) add_determination vals self.save end |
#inspect ⇒ Object
Creates a string representation of self.
117 118 119 |
# File 'lib/specify/models/collection_object.rb', line 117 def inspect to_s end |
#to_s ⇒ Object
Creates a string representation of self.
122 123 124 |
# File 'lib/specify/models/collection_object.rb', line 122 def to_s "#{catalog_number} cataloged by #{cataloger}, #{cataloged_date}" end |