Class: SequencescapeExcel::SpecialisedField::ControlType

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
app/sequencescape_excel/sequencescape_excel/specialised_field/control_type.rb

Overview

Sets both control and control_type fields on the sample

Instance Attribute Summary

Attributes included from Base

#sample_manifest_asset, #value

Instance Method Summary collapse

Methods included from Base

#link

Instance Method Details

#check_control_type_matches_enumObject


24
25
26
27
28
# File 'app/sequencescape_excel/sequencescape_excel/specialised_field/control_type.rb', line 24

def check_control_type_matches_enum
  return if value.blank? || Sample.control_types.include?(value)

  errors.add(:base, "the control type #{value} was not recognised.")
end

#update(_attributes = {}) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
# File 'app/sequencescape_excel/sequencescape_excel/specialised_field/control_type.rb', line 12

def update(_attributes = {})
  return unless valid?

  if value.present?
    sample.control = true
    sample.control_type = value
  else
    sample.control = false
    sample.control_type = nil
  end
end