Class: ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
Squishify
Includes:
Warren::Callback
Defined in:
app/models/application_record.rb

Overview

Basic base class for all ActiveRecord::Base records in Sequencescape

Direct Known Subclasses

Aker::Container, Aker::Job, Aliquot, AliquotIndex, ApiApplication, Asset, AssetAudit, AssetBarcode, AssetCreation, AssetCreation::ParentAssociation, AssetGroup, AssetGroupAsset, AssetLink, AssetShape, BaitLibrary, BaitLibrary::Supplier, BaitLibraryLayout, BaitLibraryType, Barcode, BarcodePrefix, BarcodePrinter, BarcodePrinterType, Batch, BatchRequest, BroadcastEvent, BudgetDivision, BulkTransfer, Comment, Control, CustomMetadatum, CustomMetadatumCollection, CustomText, DataReleaseStudyType, DbFile, Descriptor, Document, Equipment, Event, ExtendedValidator, ExtendedValidator::RequestTypeExtendedValidator, ExternalProperty, ExtractionAttribute, FacultySponsor, Failure, Identifier, Implement, Item, LabEvent, LibraryType, LibraryTypesRequestType, LocationReport, Lot, LotType, Map, Messenger, MessengerCreator, Metadata::Base, Order, OrderRole, Permission, PickList, Pipeline, PipelineRequestInformationType, PipelinesRequestType, Plate::Creator, Plate::Creator::ParentPurposeRelationship, Plate::Creator::PurposeRelationship, PlateConversion, PlateOwner, PlateType, PlateVolume, PreCapturePool, PreCapturePool::PooledRequest, PrimerPanel, Product, ProductCatalogue, ProductCriteria, ProductLine, ProductProductCatalogue, Program, Project, ProjectManager, Purpose, Purpose::Relationship, QcAssay, QcDecision, QcDecision::QcDecisionQcable, QcFile, QcMetric, QcMetricRequest, QcReport, QcResult, Qcable, QcableCreator, RackedTube, ReferenceGenome, Request, RequestClassDeprecator::Request, RequestEvent, RequestInformation, RequestInformationType, RequestType, RequestType::PoolingMethod, RequestType::RequestTypePlatePurpose, RequestType::Validator, Robot, RobotProperty, Role, Role::UserRole, Sample, SampleJob, SampleManifest, SampleManifestAsset, SangerSampleId, Search, SpecificTubeCreation::ChildPurpose, Stamp, Stamp::StampQcable, StateChange, Study, StudyReport, StudySample, StudyType, Submission, SubmissionPool, SubmissionTemplate, SubmissionTemplateRequestType, SubmittedAsset, Supplier, Tag, Tag2Layout, Tag2Layout::TemplateSubmission, Tag2LayoutTemplate, TagGroup, TagGroup::AdapterType, TagLayout, TagLayout::TemplateSubmission, TagLayoutTemplate, Task, Transfer, Transfer::BetweenPlateAndTubes::WellToTube, TransferRequest, TransferRequestCollection, TransferRequestCollectionTransferRequest, TransferTemplate, TubeCreation::ChildTube, TubeRackStatus, User, Uuid, VolumeUpdate, Well::Link, WellAttribute, WorkCompletion, WorkCompletionsSubmission, WorkOrder, WorkOrderType, Workflow

Class Method Summary collapse

Methods included from Squishify

extended

Class Method Details

.convert_labware_to_receptacle_for(*associations) ⇒ Object

Temporary compatibility layer following AssetRefactor: will allow labware to get passed into associations expecting receptacles where there is no ambiguity. (e.g. tubes)

Examples:

convert_labware_to_receptacle_for :library
def library=(library)
  return super if library.is_a?(Receptacle)
  Rails.logger.warn("#{library.class.name} passed to library")
  super(library.receptacle)
end

54
55
56
57
58
59
60
61
62
63
# File 'app/models/application_record.rb', line 54

def convert_labware_to_receptacle_for(*associations)
  associations.each do |assn|
    define_method("#{assn}=") do |associated|
      return super(associated) if associated.is_a?(Receptacle)

      Rails.logger.warn("#{associated.class.name} passed to #{assn}")
      super(associated&.receptacle)
    end
  end
end

.find_by_id_or_name(id, name) ⇒ Object

Raises:

  • (StandardError)

37
38
39
40
41
42
# File 'app/models/application_record.rb', line 37

def find_by_id_or_name(id, name)
  return find(id) if id.present?
  raise StandardError, 'Must specify at least ID or name' if name.blank?

  find_by(name: name)
end

.find_by_id_or_name!(id, name) ⇒ Object


33
34
35
# File 'app/models/application_record.rb', line 33

def find_by_id_or_name!(id, name)
  find_by_id_or_name(id, name) || raise(ActiveRecord::RecordNotFound, "Could not find #{self.name}: #{id || name}")
end