Module: Request::LibraryManufacture

Included in:
LibraryCreationRequest
Defined in:
app/models/request/library_manufacture.rb

Overview

Any request involved in building a library should include this module that defines some of the most common behaviour, namely the library type and insert size information.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/request/library_manufacture.rb', line 4

def self.included(base)
  base::Metadata.class_eval do
    custom_attribute(:fragment_size_required_from, required: true, integer: true, on: :create, minimum: 1)
    custom_attribute(:fragment_size_required_to,   required: true, integer: true, on: :create, minimum: 1)
    custom_attribute(:library_type,                required: true, validator: true, selection: true, on: :create)
  end

  base.class_eval do
    extend ClassMethods
  end

  base.const_set(:RequestOptionsValidator, Class.new(DelegateValidation::Validator) do
    delegate_attribute :fragment_size_required_from, :fragment_size_required_to, to: :target, type_cast: :to_i
    validates_numericality_of :fragment_size_required_from, integer_only: true, greater_than: 0
    validates_numericality_of :fragment_size_required_to,   integer_only: true, greater_than: 0
  end)
end

Instance Method Details

#insert_sizeObject


28
29
30
31
32
33
# File 'app/models/request/library_manufacture.rb', line 28

def insert_size
  Aliquot::InsertSize.new(
    .fragment_size_required_from,
    .fragment_size_required_to
  )
end