Class: Specimen
- Inherits:
-
CollectionObject::BiologicalCollectionObject
- Object
- CollectionObject::BiologicalCollectionObject
- Specimen
- 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.
Instance Attribute Summary collapse
-
#total ⇒ 1
A specimen always has a total of one.
Instance Method Summary collapse
- #check_and_set_total ⇒ Object protected
Instance Attribute Details
#total ⇒ 1
Returns 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 26 |
# File 'app/models/specimen.rb', line 8 class Specimen < CollectionObject::BiologicalCollectionObject is_origin_for 'Specimen', 'Extract', 'AssertedDistribution', 'Sequence' originates_from 'Specimen', 'Lot', 'RangedLot' 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
#check_and_set_total ⇒ Object (protected)
20 21 22 23 24 |
# File 'app/models/specimen.rb', line 20 def check_and_set_total if self.total.blank? self.total ||= 1 end end |