Module: ModelExtensions::Sample
- Included in:
- Sample
- Defined in:
- app/api/model_extensions/sample.rb
Overview
TODO:
Rails relationships should probably be moved to Sample
Included in Sample The intent of this file was to provide methods specific to the V1 API
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/api/model_extensions/sample.rb', line 6 def self.included(base) base.class_eval do scope :include_studies, -> { includes(studies: :study_metadata) } has_one :primary_study_samples, -> { order(:study_id) }, class_name: 'StudySample' has_one :primary_study, through: :primary_study_samples, source: :study has_one :primary_study_metadata, through: :primary_study, source: :study_metadata has_one :study_reference_genome, through: :primary_study_metadata, source: :reference_genome end end |
Instance Method Details
#sample_reference_genome_name ⇒ Object
17 18 19 |
# File 'app/api/model_extensions/sample.rb', line 17 def sample_reference_genome_name sample_reference_genome.try(:name) end |
#sample_reference_genome_name=(name) ⇒ Object
21 22 23 |
# File 'app/api/model_extensions/sample.rb', line 21 def sample_reference_genome_name=(name) .reference_genome = ReferenceGenome.find_by(name:) end |