Module: Aliquot::Aliquotable
- Included in:
- Sample
- Defined in:
- app/models/aliquot/aliquotable.rb
Overview
Something that is aliquotable can be part of an aliquot. So sample and tag are both examples.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength.
Class Method Details
.included(base) ⇒ Object
rubocop:todo Metrics/AbcSize, Metrics/MethodLength
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/aliquot/aliquotable.rb', line 5 def self.included(base) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength base.class_eval do extend ClassMethods has_many :aliquots has_many :receptacles, -> { distinct }, through: :aliquots has_one :primary_aliquot, -> { order('created_at ASC, aliquots.id ASC').readonly }, class_name: 'Aliquot' has_one :primary_receptacle, lambda { order('aliquots.created_at ASC, aliquots.id ASC') }, through: :primary_aliquot, source: :receptacle has_many :requests, through: :assets has_many :submissions, through: :requests scope :contained_in, ->(receptacles) { joins(:receptacles).where(receptacles: { id: receptacles }) } end end |