Class: Sequencescape::Api::V2::Tube
- Inherits:
-
Base
- Object
- Base
- Sequencescape::Api::V2::Tube
- Includes:
- Shared::HasBarcode, Shared::HasPurpose, Shared::HasRequests, Shared::HasWorklineIdentifier
- Defined in:
- app/sequencescape/sequencescape/api/v2/tube.rb
Overview
Tubes can be barcoded, but only have one receptacle for samples.
Constant Summary collapse
- DEFAULT_INCLUDES =
[ :purpose, 'receptacle.aliquots.request.request_type', 'receptacle.requests_as_source.request_type' ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #aliquots ⇒ Object
-
#model_name ⇒ ActiveModel::Name
Override the model used in form/URL helpers to allow us to treat old and new api the same.
- #stock_plate(purpose_names: SearchHelper.stock_plate_names) ⇒ Object
-
#to_param ⇒ Object
Currently us the uuid as our main identifier, might switch to human barcode soon.
Class Method Details
.find_all(params) ⇒ Object
43 44 45 46 47 48 |
# File 'app/sequencescape/sequencescape/api/v2/tube.rb', line 43 def self.find_all(params) = params.dup includes = .delete(:includes) || DEFAULT_INCLUDES paginate = .delete(:paginate) || {} Sequencescape::Api::V2::Tube.includes(*includes).where(**).paginate(paginate).all end |
.find_by(params) ⇒ Object
37 38 39 40 41 |
# File 'app/sequencescape/sequencescape/api/v2/tube.rb', line 37 def self.find_by(params) = params.dup includes = .delete(:includes) || DEFAULT_INCLUDES Sequencescape::Api::V2::Tube.includes(*includes).find(**).first end |
Instance Method Details
#aliquots ⇒ Object
33 34 35 |
# File 'app/sequencescape/sequencescape/api/v2/tube.rb', line 33 def aliquots receptacle&.aliquots end |
#model_name ⇒ ActiveModel::Name
Override the model used in form/URL helpers to allow us to treat old and new api the same
58 59 60 |
# File 'app/sequencescape/sequencescape/api/v2/tube.rb', line 58 def model_name ::ActiveModel::Name.new(Limber::Tube, false) end |
#stock_plate(purpose_names: SearchHelper.stock_plate_names) ⇒ Object
67 68 69 70 71 |
# File 'app/sequencescape/sequencescape/api/v2/tube.rb', line 67 def stock_plate(purpose_names: SearchHelper.stock_plate_names) # this is an array not a collection so cant use order_by # max_by naturally sorts in ascending order @stock_plate ||= ancestors.where(purpose_name: purpose_names).max_by(&:id) end |
#to_param ⇒ Object
Currently us the uuid as our main identifier, might switch to human barcode soon
63 64 65 |
# File 'app/sequencescape/sequencescape/api/v2/tube.rb', line 63 def to_param uuid end |