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


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

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.now
    end
  end
end

.create_assets_requests(assets, study) ⇒ Object


13
14
15
16
# File 'app/models/request_factory.rb', line 13

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


18
19
20
21
# File 'app/models/request_factory.rb', line 18

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