Class: ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ApplicationRecord
- 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
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, FlowcellType, FlowcellTypesRequestType, Identifier, Implement, Insdc::Country, 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, PolyMetadatum, 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, SampleCompoundComponent, 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, TagSet, 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
-
.alias_association(new_name, old_name) ⇒ Object
Defining alias_association to provide an alias for an association (instead of an attribute).
-
.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.
- .find_by_id_or_name(id, name) ⇒ Object
- .find_by_id_or_name!(id, name) ⇒ Object
Methods included from Squishify
Class Method Details
.alias_association(new_name, old_name) ⇒ Object
Defining alias_association to provide an alias for an association (instead of an attribute)
75 76 77 78 79 80 81 |
# File 'app/models/application_record.rb', line 75 def self.alias_association(new_name, old_name) # Define the getter define_method(new_name) { send(old_name) } # Define the setter define_method(:"#{new_name}=") { |new_value| send(:"#{old_name}=", new_value) } end |
.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)
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
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:) 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 |