Class: Specimen

Inherits:
CollectionObject::BiologicalCollectionObject show all
Defined in:
app/models/specimen.rb

Overview

A Specimen is a single (by single we mean a curator has enumerated the object as 1), physical, and biological individual that has been collected.

Constant Summary

Constant Summary

Constants inherited from CollectionObject

CollectionObject::BUFFERED_ATTRIBUTES, CollectionObject::CO_OTU_HEADERS

Constants included from CollectionObject::DwcExtensions

CollectionObject::DwcExtensions::DWC_OCCURRENCE_MAP

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary (collapse)

Attributes inherited from CollectionObject

#accessioned_at, #buffered_collecting_event, #buffered_determinations, #buffered_other_labels, #collecting_event_id, #deaccession_reason, #deaccessioned_at, #no_cached, #preparation_type_id, #project_id, #ranged_lot_category_id, #respository_id, #type

Attributes included from CollectionObject::DwcExtensions

#taxonomy

Instance Method Summary (collapse)

Methods inherited from CollectionObject::BiologicalCollectionObject

#current_taxon_determination=, #reorder_determinations_by, #sv_missing_collecting_event, #sv_missing_determination, #sv_missing_preparation_type, #sv_missing_repository

Methods inherited from CollectionObject

#add_to_dwc_occurrence, #annotations, #assign_type_if_total_or_ranged_lot_category_id_provided, bc_attributes, bc_headers, #biological?, breakdown_buffered, breakdown_status, ce_attributes, ce_headers, #check_that_both_of_category_and_total_are_not_present, #check_that_either_total_or_ranged_lot_category_id_is_present, co_attributes, co_headers, earliest_date, find_for_autocomplete, from_collecting_events, generate_report_download, in_date_range, in_geographic_item, latest_date, #missing_determination, #name_at_rank_string, #preferred_catalog_number, #reject_collecting_event, #reject_taxon_determinations, selected_column_names, #sv_missing_accession_fields, #sv_missing_collecting_event, #sv_missing_deaccession_fields, #sv_missing_preparation_type, #sv_missing_repository

Methods included from CollectionObject::DwcExtensions

#dwc_catalog_number, #dwc_country, #dwc_county, #dwc_event_date, #dwc_event_time, #dwc_family, #dwc_genus, #dwc_georeference_protocol, #dwc_institution_code, #dwc_institution_id, #dwc_latitude, #dwc_locality, #dwc_longitude, #dwc_nomenclatural_code, #dwc_preparations, #dwc_scientific_name, #dwc_specific_epithet, #dwc_state_province, #dwc_taxon_name_authorship, #dwc_verbatim_locality, #set_taxonomy

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Methods included from Housekeeping

#has_polymorphic_relationship?

Instance Attribute Details

- (1) total

Returns a specimen always has a total of one.

Returns:

  • (1)

    a specimen always has a total of one.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/specimen.rb', line 8

class Specimen < CollectionObject::BiologicalCollectionObject

  has_many :protocol_relationships, as: :protocol_relationship_object

  with_options if: 'self.type == "Specimen"' do |s|
    s.before_validation :check_and_set_total
    s.validates :total, :inclusion => { :in => 1..1 }, presence: true
  end

  protected

  def check_and_set_total
    if self.total.blank?
      self.total ||= 1  
    end
  end

end

Instance Method Details

- (Object) check_and_set_total (protected)



19
20
21
22
23
# File 'app/models/specimen.rb', line 19

def check_and_set_total
  if self.total.blank?
    self.total ||= 1  
  end
end