2022-11-28 15:54:14 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-12-01 09:37:00 +01:00
|
|
|
module DossierPrefillableConcern
|
2022-11-28 15:54:14 +01:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2023-01-03 14:46:10 +01:00
|
|
|
def prefill!(champs_public_attributes)
|
2023-01-19 11:51:56 +01:00
|
|
|
return unless champs_public_attributes.any?
|
|
|
|
|
2023-01-03 14:46:10 +01:00
|
|
|
attr = { prefilled: true }
|
2023-01-19 11:51:56 +01:00
|
|
|
attr[:champs_public_attributes] = champs_public_attributes.map { |h| h.merge(prefilled: true) }
|
2022-11-28 15:54:14 +01:00
|
|
|
|
2023-01-03 14:46:10 +01:00
|
|
|
assign_attributes(attr)
|
2022-11-28 15:54:14 +01:00
|
|
|
save(validate: false)
|
|
|
|
end
|
|
|
|
end
|