Class: Task Deprecated

Inherits:
ApplicationRecord show all
Defined in:
app/models/task.rb

Overview

Deprecated.

Task form a large number of legacy pipelines in Sequencescape, however most

Note:

A large number of tasks delegate a large portion of their behaviour back to the

A Task forms part of a Workflow which in turn describes the steps that form a Pipeline. Most tasks are a subclass of Task

more recent pipelines exist outside of Sequencescape itself.

Tasks have three key methods #render_task: Which handles rendering the form displayed to the user #do_task: Which takes the parameters from the form, and performs the task in question #partial: Inicates which partial to render when displaying the form.

WorkflowsController. This behaviour is mostly defined in modules under Task.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Class Method Details

.get_subclass_attribute_options(name) ⇒ Object


76
77
78
79
# File 'app/models/task.rb', line 76

def self.get_subclass_attribute_options(name)
  init_class
  @subclass_attributes[name]
end

.get_subclass_attributesObject


85
86
87
88
# File 'app/models/task.rb', line 85

def self.get_subclass_attributes
  init_class
  @subclass_attributes_ordered_names
end

.init_classObject


68
69
70
71
72
73
74
# File 'app/models/task.rb', line 68

def self.init_class
  return if @init_done

  @init_done = true
  @subclass_attributes = {}
  @subclass_attributes_ordered_names = []
end

.set_subclass_attribute(name, options = {}) ⇒ Object

Raises:

  • (ArgumentError)

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'app/models/task.rb', line 94

def self.set_subclass_attribute(name, options = {})
  init_class
  raise ArgumentError, "subclass attribute #{name} already in use" if @subclass_attributes.include? name

  @subclass_attributes[name] = options
  @subclass_attributes_ordered_names << name

  kind = options[:kind]
  cast = options[:cast]
  default_value = options[:default]

  define_method(name) do
    value = get_subclass_attribute_value name, default_value # we love closure :)
    value and case cast
              when :int
                value.to_i
              else
                value
              end
  end

  define_method("#{name}=") do |value|
    set_subclass_attribute_value(name, value, kind)
  end
end

Instance Method Details

#do_task(_controller, _params) ⇒ Object

Raises:

  • (NotImplementedError)

137
138
139
# File 'app/models/task.rb', line 137

def do_task(_controller, _params)
  raise NotImplementedError, "Please Implement a do_task for #{self.class.name}"
end

#find_batch(batch_id) ⇒ Object


145
146
147
# File 'app/models/task.rb', line 145

def find_batch(batch_id)
  Batch.includes(:requests, :pipeline, :lab_events).find(batch_id)
end

#find_batch_requests(batch_id) ⇒ Object


149
150
151
# File 'app/models/task.rb', line 149

def find_batch_requests(batch_id)
  find_batch(batch_id).ordered_requests
end

#get_descriptor_value(name, default = nil) ⇒ Object

TODO: move into SetDescriptorsTask


23
24
25
26
27
28
29
30
31
# File 'app/models/task.rb', line 23

def get_descriptor_value(name, default = nil)
  name_s = name.to_s
  descriptors.each do |desc|
    if desc.name.eql?(name_s)
      return desc.value
    end
  end
  default
end

#get_subclass_attribute_options(name) ⇒ Object


81
82
83
# File 'app/models/task.rb', line 81

def get_subclass_attribute_options(name)
  self.class.get_subclass_attribute_options(name)
end

#get_subclass_attribute_value(name, default = nil) ⇒ Object


47
48
49
50
51
52
53
54
55
# File 'app/models/task.rb', line 47

def get_subclass_attribute_value(name, default = nil)
  name_s = name.to_s
  subclass_attributes.each do |desc|
    if desc.name.eql?(name_s)
      return desc.value
    end
  end
  default
end

#get_subclass_attributesObject


90
91
92
# File 'app/models/task.rb', line 90

def get_subclass_attributes
  self.class.get_subclass_attributes
end

#included_for_do_taskObject


125
126
127
# File 'app/models/task.rb', line 125

def included_for_do_task
  %i[requests pipeline lab_events]
end

#included_for_render_taskObject


129
130
131
# File 'app/models/task.rb', line 129

def included_for_render_task
  %i[requests pipeline lab_events]
end

#partialObject

END of subclass_to_attiribuet


122
123
# File 'app/models/task.rb', line 122

def partial
end

#render_task(controller, params) ⇒ Object


133
134
135
# File 'app/models/task.rb', line 133

def render_task(controller, params)
  controller.render_task(self, params)
end

#set_descriptor_value(name, value, _kind = nil) ⇒ Object


33
34
35
36
37
38
39
40
41
42
# File 'app/models/task.rb', line 33

def set_descriptor_value(name, value, _kind = nil)
  name_s = name.to_s
  descriptors.each do |desc|
    if desc.name.eql?(name_s)
      desc.value = value
      return
    end
  end
  descriptors << Descriptor.new(name: name_s, value: value)
end

#set_subclass_attribute_value(name, value, _kind = nil) ⇒ Object


57
58
59
60
61
62
63
64
65
66
# File 'app/models/task.rb', line 57

def set_subclass_attribute_value(name, value, _kind = nil)
  name_s = name.to_s
  subclass_attributes.each do |desc|
    if desc.name.eql?(name_s)
      desc.value = value
      return
    end
  end
  subclass_attributes << SubclassAttribute.new(name: name_s, value: value)
end

#sub_events_for(_event) ⇒ Object


141
142
143
# File 'app/models/task.rb', line 141

def sub_events_for(_event)
  []
end