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



63
64
65
# File 'app/models/tag_set.rb', line 63

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



54
55
56
57
# File 'app/models/tag_set.rb', line 54

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



59
60
61
# File 'app/models/tag_set.rb', line 59

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.



49
50
51
# File 'app/models/tag_set.rb', line 49

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