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

Accession::SampleStatus, 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, SpecificTubeRackCreation::ChildPurpose, SpecificTubeRackCreation::ChildTubeRack, 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, UltimaGlobal, User, Uuid, VolumeUpdate, Well::Link, WellAttribute, WorkCompletion, WorkCompletionsSubmission, WorkOrder, WorkOrderType, Workflow

Class Method Summary collapse

Methods included from Squishify

extended

Class Method Details

.alias_association(new_name, old_name) ⇒ Object

Defining alias_association to provide an alias for an association (instead of an attribute)

Examples:

alias_association :labware, :receptacle
def labware=(labware)
  return super if labware.is_a?(Receptacle)
  super(labware.receptacle)
end

Parameters:

  • new_name (Symbol)

    The new name of the association

  • old_name (Symbol)

    The old name of the association (the one that already exists on the model



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/models/application_record.rb', line 75

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
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)

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
64
65
66
67
68
69
70
71
72
73
74
# File 'app/models/application_record.rb', line 54

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

.find_by_id_or_name(id, name) ⇒ Object

Raises:

  • (StandardError)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/application_record.rb', line 37

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end

.find_by_id_or_name!(id, name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/application_record.rb', line 33

 do
  # NOTE: The following attribute is not required for Microarray Genotyping.
  # I think this might be broken and suggests that there should be separate classes for project: one for
  # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping
  # that doesn't.
  include ProjectManager::Associations
  include BudgetDivision::Associations

  custom_attribute(:project_cost_code, required: true)
  custom_attribute(:funding_comments)
  custom_attribute(:collaborators)
  custom_attribute(:external_funding_source)
  custom_attribute(:sequencing_budget_cost_centre)
  custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS)
  custom_attribute(:gt_committee_tracking_id)

  before_validation do |record|
    record.project_cost_code = nil if record.project_cost_code.blank?
    record.project_funding_model = nil if record.project_funding_model.blank?
  end
end