21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/unidom/article_number/marking.rb', line 21
def self.mark!(barcode: nil, marked: nil, marker: nil, opened_at: Time.now)
raise ArgumentError.new('The barcode argument is required.' ) if barcode.blank?
raise ArgumentError.new('The marked argument is required.' ) if marked.blank?
raise ArgumentError.new('The opened_at argument is required.') if opened_at.blank?
query = barcode_is(barcode).marked_is(marked).valid_at.alive
creation = { opened_at: opened_at }
if marker.present? && marker.respond_to?(:id)
creation[:marker] = marker
else
creation[:marker_id] = Unidom::Common::NULL_UUID
creation[:marker_type] = ''
end
query.first_or_create! creation
end
|