Class: Tube
- Inherits:
-
Labware
- Object
- ActiveRecord::Base
- ApplicationRecord
- Asset
- Labware
- Tube
- Extended by:
- QcFile::Associations
- Includes:
- Api::Messages::QcResultIo::TubeExtensions, Asset::Ownership::Unowned, Barcode::Barcodeable, ModelExtensions::Tube, SingleReceptacleLabware, Tag::Associations, Transfer::Associations, Transfer::State::TubeState
- Defined in:
- app/models/tube.rb
Overview
A Tube is a piece of Labware
Direct Known Subclasses
LibraryTube, MultiplexedLibraryTube, PacBioLibraryTube, PulldownMultiplexedLibraryTube, SampleTube, StockLibraryTube, StockMultiplexedLibraryTube
Defined Under Namespace
Modules: AttributeUpdater Classes: Purpose, StandardMx, StockMx
Instance Attribute Summary
Attributes inherited from Labware
Class Method Summary collapse
- .create_with_barcode!(*args) ⇒ Object
-
.delegate_to_purpose(*methods) ⇒ Object
Delegates the provided methods to purpose, passing the tube as the first argument, and the remaining arguments as-is.
Instance Method Summary collapse
- #after_comment_addition(comment) ⇒ Object
- #barcode! ⇒ Object
- #comments ⇒ Object
- #details ⇒ Object
- #name_for_child_tube ⇒ Object
- #name_for_label ⇒ Object
- #pool_id ⇒ Object
- #sanger_barcode=(attributes) ⇒ Object
-
#stock_plate ⇒ Plate
Returns the stock plate of the tube, behaviour delegated to purpose.
- #subject_type ⇒ Object
- #submission ⇒ Object
Methods included from QcFile::Associations
Methods included from SingleReceptacleLabware
Methods included from Transfer::State::TubeState
Methods included from Transfer::Associations
Methods included from Asset::Ownership::Unowned
Methods included from Tag::Associations
Methods included from Barcode::Barcodeable
#any_barcode_matching?, #barcode_format, #barcode_number, #cgap_barcode, #cgap_barcode=, #external_barcode, #external_barcode=, #external_identifier, #fluidigm_barcode, #fluidigm_barcode=, #foreign_barcode=, #generate_barcode, included, #infinium_barcode, #infinium_barcode=, #prefix, #primary_barcode, #printable_target, #sanger_barcode
Methods inherited from Labware
#ancestor_of_purpose, #ancestors_of_purpose, #child, #display_name, #external_identifier, find_by_barcode, find_from_any_barcode, #generate_name, #labware, #labwhere_location, labwhere_locations, #parent, #received_date, #retention_instructions, #role, #scanned_in_date, #source_plate, #source_plates, #spiked_in_buffer, #state, #storage_location
Methods included from SharedBehaviour::Named
Methods included from AssetLink::Associations
Methods included from Uuid::Uuidable
included, #unsaved_uuid!, #uuid
Methods inherited from Asset
#ancestor_of_purpose, #asset_type_for_request_types, #barcode_number, #compatible_purposes, #contained_samples, #generate_barcode, #get_qc_result_value_for, #has_stock_asset?, #label, #label=, #original_stock_plates, #prefix, #printable?, #printable_target, #register_stock!, #request_types, #type, #update_from_qc
Methods included from EventfulRecord
#has_many_events, #has_many_lab_events, #has_one_event_with_family
Methods included from Event::PlateEvents
#event_date, #fluidigm_stamp_date, #gel_qc_date, #pico_date, #qc_started_date, #sequenom_stamp_date
Methods inherited from ApplicationRecord
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
Class Method Details
.create_with_barcode!(*args) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/models/tube.rb', line 86 def self.(*args, &) attributes = args..symbolize_keys , prefix = (args, attributes) (, prefix) if .present? ||= AssetBarcode. # remove this so it's not passed in on creation, and set it explicitly afterwards # this is to control the order of barcode addition so that it gets set as the 'primary' barcode = attributes.delete(:foreign_barcode) tube = create!(attributes.merge(sanger_barcode: { prefix: prefix, number: }), &) tube. = if tube.reload end |
.delegate_to_purpose(*methods) ⇒ Object
Delegates the provided methods to purpose, passing the tube as the first argument, and the remaining arguments as-is
51 52 53 |
# File 'app/models/tube.rb', line 51 def self.delegate_to_purpose(*methods) methods.each { |method| class_eval("def #{method}(*args, &block) ; purpose.#{method}(self, *args, &block) ; end") } end |
Instance Method Details
#after_comment_addition(comment) ⇒ Object
82 83 84 |
# File 'app/models/tube.rb', line 82 def after_comment_addition(comment) comments.add_comment_to_submissions(comment) end |
#barcode! ⇒ Object
25 26 27 28 |
# File 'app/models/tube.rb', line 25 def self. = { number: AssetBarcode., prefix: default_prefix } unless save! end |
#comments ⇒ Object
32 33 34 |
# File 'app/models/tube.rb', line 32 def comments @comments ||= CommentsProxy::Tube.new(self) end |
#details ⇒ Object
78 79 80 |
# File 'app/models/tube.rb', line 78 def details purpose.try(:name) || 'Tube' end |
#name_for_child_tube ⇒ Object
70 71 72 |
# File 'app/models/tube.rb', line 70 def name_for_child_tube name end |
#name_for_label ⇒ Object
44 45 46 |
# File 'app/models/tube.rb', line 44 def name_for_label primary_sample&.shorten_sanger_sample_id.presence || name end |
#pool_id ⇒ Object
40 41 42 |
# File 'app/models/tube.rb', line 40 def pool_id submissions.ids.first end |
#sanger_barcode=(attributes) ⇒ Object
74 75 76 |
# File 'app/models/tube.rb', line 74 def (attributes) << Barcode.build_sanger_ean13(attributes) end |
#stock_plate ⇒ Plate
Returns the stock plate of the tube, behaviour delegated to purpose
66 |
# File 'app/models/tube.rb', line 66 delegate_to_purpose(:stock_plate) |
#subject_type ⇒ Object
21 22 23 |
# File 'app/models/tube.rb', line 21 def subject_type 'tube' end |
#submission ⇒ Object
36 37 38 |
# File 'app/models/tube.rb', line 36 def submission submissions.first end |