Class: IlluminaHtp::StockTubePurpose

Inherits:
Tube::Purpose
  • Object
show all
Defined in:
app/models/illumina_htp/stock_tube_purpose.rb

Direct Known Subclasses

InitialStockTubePurpose

Instance Method Summary collapse

Instance Method Details

#create_with_request_options(_tube) ⇒ Object


2
3
4
# File 'app/models/illumina_htp/stock_tube_purpose.rb', line 2

def create_with_request_options(_tube)
  raise 'Unimplemented behaviour'
end

#outer_requests_for(tube) ⇒ Object


16
17
18
19
20
# File 'app/models/illumina_htp/stock_tube_purpose.rb', line 16

def outer_requests_for(tube)
  tube.requests_as_target.map do |r|
    r.submission.requests.where_is_a(LibraryCompletion)
  end.uniq
end

#stock_plate(tube) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/illumina_htp/stock_tube_purpose.rb', line 27

def stock_plate(tube)
  return nil if tube.transfer_requests_as_target.empty?

  assets = [tube.transfer_requests_as_target.first.asset]
  until assets.empty?
    asset = assets.shift
    return asset.plate if asset.is_a?(Well) and asset.plate.stock_plate?

    assets.push(asset.transfer_requests_as_target.first.asset).compact
  end

  raise "Cannot locate stock plate for #{tube.display_name.inspect}"
end

#stock_wells(tube) ⇒ Object


41
42
43
44
45
# File 'app/models/illumina_htp/stock_tube_purpose.rb', line 41

def stock_wells(tube)
  tube.requests_as_target.map do |request|
    request.asset.stock_wells
  end.flatten
end

#transition_to(tube, state, _user, _ = nil, customer_accepts_responsibility = false) ⇒ Object


6
7
8
9
10
11
12
13
14
# File 'app/models/illumina_htp/stock_tube_purpose.rb', line 6

def transition_to(tube, state, _user, _ = nil, customer_accepts_responsibility = false)
  tube.transfer_requests_as_target.where.not(state: terminated_states).find_each do |request|
    request.transition_to(state)
  end
  outer_requests_for(tube).each do |request|
    request.customer_accepts_responsibility! if customer_accepts_responsibility
    request.transition_to(state)
  end if terminated_states.include?(state)
end