Class: TagSet

Inherits:
ApplicationRecord show all
Includes:
Uuid::Uuidable
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 included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

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



66
67
68
# File 'app/models/tag_set.rb', line 66

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



56
57
58
59
60
# File 'app/models/tag_set.rb', line 56

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



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

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.



51
52
53
# File 'app/models/tag_set.rb', line 51

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