Class: TagSet

Inherits:
ApplicationRecord show all
Defined in:
app/models/tag_set.rb

Overview

Links together two related tag groups - i7 and i5 - to represent a dual index tag set It can also be used to represent single index tag sets Background explained in Y24-170 (github.com/sanger/sequencescape/issues/4160)

Instance Method Summary collapse

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#tag2_group_name=(name) ⇒ Object



45
46
47
# File 'app/models/tag_set.rb', line 45

def tag2_group_name=(name)
  self.tag2_group = TagGroup.find_by!(name:)
end

#tag_group_adapter_types_must_matchObject

Method to determine that both tag groups have the same adapter type



36
37
38
39
# File 'app/models/tag_set.rb', line 36

def tag_group_adapter_types_must_match
  return unless tag2_group && tag_group.adapter_type != tag2_group.adapter_type
  errors.add(:tag_group, 'Adapter types of tag groups must match')
end

#tag_group_name=(name) ⇒ Object



41
42
43
# File 'app/models/tag_set.rb', line 41

def tag_group_name=(name)
  self.tag_group = TagGroup.find_by!(name:)
end

#visibleObject

Dynamic method to determine the visibility of a tag_set based on the visibility of its tag_groups TagSet has a method to check if itself is visible by checking the visibility of both tag_group and (if not null) tag2_group.



31
32
33
# File 'app/models/tag_set.rb', line 31

def visible
  tag_group.visible && (tag2_group.nil? || tag2_group.visible)
end