Module: Heron::Factories::Concerns::ForeignBarcodes
- Defined in:
- app/models/heron/factories/concerns/foreign_barcodes.rb
Overview
A foreign barcode is a barcode that has been externally set, that is added as another extra barcode for the labware referred. This module adds validation and processing methods for this barcodes
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/models/heron/factories/concerns/foreign_barcodes.rb', line 11 def self.included(klass) klass.instance_eval do attr_accessor :barcode validates :barcode, presence: true validate :check_barcode_format, :check_foreign_barcode_unique end end |
Instance Method Details
#barcode_format ⇒ Object
20 21 22 |
# File 'app/models/heron/factories/concerns/foreign_barcodes.rb', line 20 def Barcode.() end |
#check_barcode_format ⇒ Object
24 25 26 27 28 |
# File 'app/models/heron/factories/concerns/foreign_barcodes.rb', line 24 def return if .present? errors.add(:base, "The barcode '#{}' is not a recognised format.") end |
#check_foreign_barcode_unique ⇒ Object
30 31 32 33 34 |
# File 'app/models/heron/factories/concerns/foreign_barcodes.rb', line 30 def return unless Barcode.exists_for_format?(, ) errors.add(:base, "The barcode '#{}' is already in use.") end |