Module: Heron::Factories::Concerns::RecipientsCoordinates

Included in:
Plate, TubeRack
Defined in:
app/models/heron/factories/concerns/recipients_coordinates.rb

Overview

Validates the object under @params to check that all keys are valid coordinates, otherwise it will add the errors to the active model instance

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



11
12
13
# File 'app/models/heron/factories/concerns/recipients_coordinates.rb', line 11

def self.included(klass)
  klass.instance_eval { validate :check_recipient_coordinates }
end

Instance Method Details

#check_recipient_coordinatesObject



15
16
17
18
19
20
21
22
# File 'app/models/heron/factories/concerns/recipients_coordinates.rb', line 15

def check_recipient_coordinates
  return unless @params[recipients_key]

  @params[recipients_key]
    .keys
    .reject { |k| coordinate_valid?(k) }
    .each { |k| errors.add(:coordinate, "The location \"#{k}\" has an invalid format") }
end