Class: RequestFactory

Inherits:
Object
  • Object
show all
Defined in:
app/models/request_factory.rb

Class Method Summary collapse

Class Method Details

.copy_request(request) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/models/request_factory.rb', line 3

def self.copy_request(request)
  ActiveRecord::Base.transaction do
    request
      .class
      .create!(request.attributes.except('id', 'created_at', 'updated_at')) do |request_copy|
        request_copy.target_asset_id = nil
        request_copy.state = 'pending'
        request_copy. = request..attributes
        request_copy.created_at = Time.zone.now
      end
  end
end

.create_assets_requests(assets, study) ⇒ Object



16
17
18
19
# File 'app/models/request_factory.rb', line 16

def self.create_assets_requests(assets, study)
  request_type = RequestType.create_asset
  assets.each { |asset| request_type.create!(study: study, asset: asset, state: 'passed') }
end

.create_external_multiplexed_library_creation_requests(sources, target, study) ⇒ Object



21
22
23
24
# File 'app/models/request_factory.rb', line 21

def self.create_external_multiplexed_library_creation_requests(sources, target, study)
  request_type = RequestType.external_multiplexed_library_creation
  sources.each { |asset| request_type.create!(study: study, asset: asset, target_asset: target) }
end