Module: SampleManifestExcel::Tags::Validator::Uniqueness

Extended by:
ActiveSupport::Concern
Includes:
ClashesFinder
Included in:
Upload::Processor::MultiplexedLibraryTube
Defined in:
app/sample_manifest_excel/sample_manifest_excel/tags/validator/uniqueness.rb

Overview

Uniqueness

Instance Method Summary collapse

Methods included from ClashesFinder

#create_tags_clashes_message, #find_tags_clash

Instance Method Details

#check_tagsObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/sample_manifest_excel/sample_manifest_excel/tags/validator/uniqueness.rb', line 16

def check_tags
  i7s = upload.data_at(:i7)
  i5s = upload.data_at(:i5)

  tag_groups = upload.data_at(:tag_group)
  tag_indexes = upload.data_at(:tag_index)
  tag2_groups = upload.data_at(:tag2_group)
  tag2_indexes = upload.data_at(:tag2_index)

  duplicates = if i7s.present? && i5s.present?
                 find_tags_clash(i7s.zip(i5s))
               elsif tag_groups.present? && tag_indexes.present? && tag2_groups.present? && tag2_indexes.present?
                 check_tag_groups_and_indexes(tag_groups, tag_indexes, tag2_groups, tag2_indexes)
               else
                 {}
               end
  errors.add(:tags_clash, create_tags_clashes_message(duplicates, FIRST_ROW)) unless duplicates.empty?
end