Class: UatActions
- Inherits:
-
Object
- Object
- UatActions
- Includes:
- ActiveModel::Model
- Defined in:
- app/uat_actions/uat_actions.rb
Overview
Base class for Uat Actions Adding a new action: 1) rails generate uat_action MyNewAction –description=My action description
Direct Known Subclasses
GenerateFluidxBarcodes, GeneratePlateConcentrations, GeneratePlates, GeneratePrimerPanel, GenerateProject, GenerateQcResults, GenerateSampleManifest, GenerateSpikedBufferTube, GenerateStudy, GenerateTagGroup, GenerateTagLayoutTemplate, GenerateTagPlates, GenerateTubeRacks, GenerateTubes, IntegrationSuiteTools, PlateInformation, TestSubmission, TubeSubmission
Defined Under Namespace
Modules: StaticRecords Classes: FormField, GenerateFluidxBarcodes, GeneratePlateConcentrations, GeneratePlates, GeneratePrimerPanel, GenerateProject, GenerateQcResults, GenerateSampleManifest, GenerateSpikedBufferTube, GenerateStudy, GenerateTagGroup, GenerateTagLayoutTemplate, GenerateTagPlates, GenerateTaggedPlates, GenerateTubeRacks, GenerateTubes, IntegrationSuiteTools, PlateInformation, TestSubmission, TubeSubmission
Constant Summary collapse
- CATEGORY_LIST =
List of categories to group UatActions by, in the order they should be displayed This is used only for display purposes and can be altered as required
%i[setup_and_test generating_samples auxiliary_data quality_control uncategorised].freeze
Class Method Summary collapse
-
.all ⇒ Array<UatAction>
Returns a list of all registered UatActions.
-
.category ⇒ Object
Default category should one not be provided.
- .default ⇒ Object
-
.find(id) ⇒ Class
Find the UatAction identified by the id (Usually the class name parameterized).
-
.form_field(attribute, type, options = {}) ⇒ void
Register a new FormField.
- .form_fields ⇒ Object
-
.grouped_and_sorted_uat_actions ⇒ Object
Returns a hash of all registered uat_actions grouped by category and sorted.
- .id ⇒ Object
-
.inherited(other) ⇒ Object
Automatically called by UatActions classes to register themselves.
- .permitted ⇒ Object
- .to_partial_path ⇒ Object
-
.uat_actions ⇒ Object
The hash of all registered uat_actions.
Instance Method Summary collapse
Class Method Details
.all ⇒ Array<UatAction>
Returns a list of all registered UatActions
26 27 28 |
# File 'app/uat_actions/uat_actions.rb', line 26 def all uat_actions.values end |
.category ⇒ Object
Default category should one not be provided
47 48 49 |
# File 'app/uat_actions/uat_actions.rb', line 47 def category UatActions::CATEGORY_LIST.last end |
.default ⇒ Object
111 112 113 |
# File 'app/uat_actions/uat_actions.rb', line 111 def default new end |
.find(id) ⇒ Class
Find the UatAction identified by the id (Usually the class name parameterized)
37 38 39 |
# File 'app/uat_actions/uat_actions.rb', line 37 def find(id) uat_actions[id] end |
.form_field(attribute, type, options = {}) ⇒ void
This method returns an undefined value.
Register a new FormField. This will be automatically rendered by the UI and any attributes will be available and instance attributes.
96 97 98 99 100 101 |
# File 'app/uat_actions/uat_actions.rb', line 96 def form_field(attribute, type, = {}) @form_fields ||= [] attr_accessor attribute @form_fields << UatActions::FormField.new(.merge(attribute:, type:)) end |
.form_fields ⇒ Object
103 104 105 |
# File 'app/uat_actions/uat_actions.rb', line 103 def form_fields @form_fields ||= [] end |
.grouped_and_sorted_uat_actions ⇒ Object
Returns a hash of all registered uat_actions grouped by category and sorted
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/uat_actions/uat_actions.rb', line 52 def grouped_and_sorted_uat_actions # raise error if any categories are not in the list all.each do |uat_action| unless CATEGORY_LIST.include?(uat_action.category) raise "Category '#{uat_action.category}' from '#{uat_action}' is not in the list" \ " of categories #{CATEGORY_LIST}" end end all.group_by(&:category).sort_by { |category, _| CATEGORY_LIST.index(category) } end |
.id ⇒ Object
77 78 79 |
# File 'app/uat_actions/uat_actions.rb', line 77 def id name.demodulize.parameterize end |
.inherited(other) ⇒ Object
Automatically called by UatActions classes to register themselves
67 68 69 70 71 |
# File 'app/uat_actions/uat_actions.rb', line 67 def inherited(other) # Register the form_fields of the parent class other.form_fields.concat(form_fields) UatActions.uat_actions[other.id] = other end |
.permitted ⇒ Object
107 108 109 |
# File 'app/uat_actions/uat_actions.rb', line 107 def permitted form_fields.map(&:attribute) end |
.to_partial_path ⇒ Object
73 74 75 |
# File 'app/uat_actions/uat_actions.rb', line 73 def to_partial_path 'uat_actions/entry' end |
.uat_actions ⇒ Object
The hash of all registered uat_actions
42 43 44 |
# File 'app/uat_actions/uat_actions.rb', line 42 def uat_actions @uat_actions ||= {} end |
Instance Method Details
#form_fields ⇒ Object
120 121 122 |
# File 'app/uat_actions/uat_actions.rb', line 120 def form_fields self.class.form_fields end |
#perform ⇒ Object
128 129 130 131 |
# File 'app/uat_actions/uat_actions.rb', line 128 def perform errors.add(:base, 'This action has not been implemented.') false end |
#report ⇒ Object
116 117 118 |
# File 'app/uat_actions/uat_actions.rb', line 116 def report @report ||= {} end |
#save ⇒ Object
124 125 126 |
# File 'app/uat_actions/uat_actions.rb', line 124 def save valid? && ActiveRecord::Base.transaction { perform } end |