Class: Specimen

Inherits:
CollectionObject::BiologicalCollectionObject
  • Object
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#total1

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
26
# File 'app/models/specimen.rb', line 8

class Specimen < CollectionObject::BiologicalCollectionObject

  is_origin_for 'Specimen', 'Extract', 'AssertedDistribution', 'Sequence'
  originates_from 'Specimen', 'Lot', 'RangedLot'

  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

#check_and_set_totalObject (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