Class: InstrumentTypeValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/instrument_type_validator.rb

Overview

Validator for Pacbio InstrumentType:

  • Validates the InstrumentType and its associated Plates and Wells

  • Validates the presence of required attributes

  • Validates the number of Plates and Wells

  • Validates the positions of Wells

  • Validates the combinations of Wells

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ InstrumentTypeValidator

Returns a new instance of InstrumentTypeValidator.

Parameters:

  • options (Hash)

Options Hash (options):

  • :instrument_types (Hash)


16
17
18
19
# File 'app/validators/instrument_type_validator.rb', line 16

def initialize(options)
  super
  @instrument_types = options[:instrument_types].with_indifferent_access
end

Instance Attribute Details

#instrument_typeObject

Returns the value of attribute instrument_type.



12
13
14
# File 'app/validators/instrument_type_validator.rb', line 12

def instrument_type
  @instrument_type
end

#instrument_typesObject (readonly)

Returns the value of attribute instrument_types.



12
13
14
# File 'app/validators/instrument_type_validator.rb', line 12

def instrument_types
  @instrument_types
end

Instance Method Details

#validate(record) ⇒ Object

validates the InstrumentType and its associated Plates and Wells

Parameters:

  • record (Run)


23
24
25
26
27
28
29
30
31
32
# File 'app/validators/instrument_type_validator.rb', line 23

def validate(record)
  self.instrument_type = record

  return if instrument_type.blank?

  # e.g. if record is a Run, then root is :run
  validate_model(record.model_name.element.to_sym, record, instrument_type['models'])

  bubble_errors(record)
end