Class: TagLayoutTemplate

Inherits:
ApplicationRecord show all
Includes:
Lot::Template, Uuid::Uuidable
Defined in:
app/models/tag_layout_template.rb

Overview

This is a layout template for tags. Think of it as a partially created TagLayout, defining only the tag group that will be used and the actual TagLayout implementation that will do the work.

Instance Method Summary collapse

Methods included from Lot::Template

included

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#create!(attributes = {}, &block) ⇒ Object

Create a TagLayout instance that does the actual work of laying out the tags.


25
26
27
28
29
30
31
32
33
# File 'app/models/tag_layout_template.rb', line 25

def create!(attributes = {}, &block)
  new_tag_layout_attributes = attributes.except(:enforce_uniqueness).merge(tag_layout_attributes)
  # By default if not overridden, dual indexed tag template enforce their uniqueness
  # We use fetch here, as both nil and false are expected values
  enforce_uniqueness = attributes.fetch(:enforce_uniqueness, tag2_group.present?)
  TagLayout.create!(new_tag_layout_attributes, &block).tap do |tag_layout|
    record_template_use(tag_layout.plate, enforce_uniqueness)
  end
end

#stamp_to(_) ⇒ Object


20
21
22
# File 'app/models/tag_layout_template.rb', line 20

def stamp_to(_)
  # Do Nothing
end

#tag2_group_name=(name) ⇒ Object


39
40
41
# File 'app/models/tag_layout_template.rb', line 39

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

#tag_group_name=(name) ⇒ Object


35
36
37
# File 'app/models/tag_layout_template.rb', line 35

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