Class: UatActions::GenerateFluidxBarcodes
- Inherits:
-
UatActions
- Object
- UatActions
- UatActions::GenerateFluidxBarcodes
- Defined in:
- app/uat_actions/uat_actions/generate_fluidx_barcodes.rb
Overview
UAT action to generate randomised FluidX barcodes in the following format: <prefix><random><suffix>: Ten characters in total <prefix>: two uppercase letters <random>: six random digits; may be truncated from the end to fit the length <suffix>: <zero><index> <zero>: one digit that separates random part and index, i.e. ‘0’ <index>: sequential tail, 1 to 3 digits, e.g., ‘9’, ‘99’, and ‘999’
Sequential tail in barcodes may be higher and may have gaps because of handling duplicates. Random part may be truncated from right to fit the length of the barcode.
Constant Summary
Constants inherited from UatActions
Class Method Summary collapse
-
.default ⇒ UatActions::GenerateFluidxBarcodes
Returns a default copy of the UatAction which will be used to fill in the form.
Instance Method Summary collapse
-
#perform ⇒ Boolean
This method is called from the save method after validations have passed.
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
.default ⇒ UatActions::GenerateFluidxBarcodes
Returns a default copy of the UatAction which will be used to fill in the form.
94 95 96 |
# File 'app/uat_actions/uat_actions/generate_fluidx_barcodes.rb', line 94 def self.default new(barcode_count: '1', barcode_prefix: 'TS', barcode_index: '1') end |
Instance Method Details
#perform ⇒ Boolean
This method is called from the save method after validations have passed. If the return value is true, the report hash populated by the action is used for rendering the response. If the return value is false, the errors collection is used.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/uat_actions/uat_actions/generate_fluidx_barcodes.rb', line 79 def perform random = generate_random = (.to_i, , random, .to_i) if .size == .to_i report['barcodes'] = true else errors.add(:base, 'Failed to generate unique barcodes') false end end |