Class: UatActions::GenerateSpikedBufferTube

Inherits:
UatActions
  • Object
show all
Defined in:
app/uat_actions/uat_actions/generate_spiked_buffer_tube.rb

Overview

Will construct a SpikedBuffer tube (contains PhiX control sample)

Constant Summary

Constants inherited from UatActions

CATEGORY_LIST

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UatActions

all, category, find, form_field, form_fields, #form_fields, grouped_and_sorted_uat_actions, id, inherited, permitted, #report, #save, to_partial_path, uat_actions

Class Method Details

.defaultUatActions::GenerateSpikedBufferTube

Returns a default copy of the UatAction which will be used to fill in the form

Returns:



24
25
26
# File 'app/uat_actions/uat_actions/generate_spiked_buffer_tube.rb', line 24

def self.default
  new(tube_count: 1)
end

Instance Method Details

#create_phix_stocks(timestamp) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/uat_actions/uat_actions/generate_spiked_buffer_tube.rb', line 48

def create_phix_stocks(timestamp)
  phi_x_stock_params = {
    name: "uat-phix-stock-#{timestamp}",
    tags: 'Dual',
    concentration: 10,
    number: 1,
    study_id: PhiX.default_study_option&.id
  }
  parent_stock = PhiX::Stock.new(phi_x_stock_params)
  return nil unless parent_stock.save

  parent_stock.created_stocks
end

#create_spiked_buffers(timestamp, parent_stocks) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/uat_actions/uat_actions/generate_spiked_buffer_tube.rb', line 62

def create_spiked_buffers(timestamp, parent_stocks)
  phi_x_spiked_buffers_params = {
    name: "uat-phix-spikedbuffer-#{timestamp}",
    parent_barcode: parent_stocks.first.human_barcode,
    concentration: 10,
    number: tube_count,
    volume: 10
  }
  spiked_buffer = PhiX::SpikedBuffer.new(phi_x_spiked_buffers_params)
  return nil unless spiked_buffer.save

  spiked_buffer.created_spiked_buffers
end

#performBoolean

[perform description]

Returns:

  • (Boolean)

    Returns true if the action was successful, false otherwise



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/uat_actions/uat_actions/generate_spiked_buffer_tube.rb', line 32

def perform
  # Called by the controller once the form is filled in. Add your actual actions here.
  # All the form fields are accessible as simple attributes.
  # Return true if everything works
  timestamp = Time.now.to_i

  parent_stocks = create_phix_stocks(timestamp)
  return false unless parent_stocks

  spiked_buffers = create_spiked_buffers(timestamp, parent_stocks)
  return false unless spiked_buffers

  spiked_buffers.each_with_index { |tube, index| report["tube_#{index}"] = tube.human_barcode }
  true
end