Class: BaitLibraryLayout

Inherits:
ApplicationRecord show all
Includes:
ModelExtensions::BaitLibraryLayout, Uuid::Uuidable
Defined in:
app/models/bait_library_layout.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

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

Class Method Details

.preview!(attributes = {}, &block) ⇒ Object

This method can be used to view a previous of what will happen when the bait libraries are laid out on a plate.


82
83
84
85
86
87
88
89
# File 'app/models/bait_library_layout.rb', line 82

def self.preview!(attributes = {}, &block)
  new(attributes, &block).tap do |layout|
    raise ActiveRecord::RecordInvalid, layout unless layout.valid?

    layout.unsaved_uuid!
    layout.send(:generate_for_preview)
  end
end

Instance Method Details

#well_layoutObject


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

def well_layout
  {}.tap { |well_to_name| layout.map { |name, locations| locations.map { |l| well_to_name[l] = name } } }
end