23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/models/unidom/certificate/certificating.rb', line 23
def self.certificate!(certification: nil, certificated: nil, certificator: nil, opened_at: Time.now)
assert_present! :certification, certification
assert_present! :certificated, certificated
assert_present! :opened_at, opened_at
attributes = { opened_at: opened_at }
if certificator.present?
attributes[:certificator] = certificator
else
attributes[:certificator_id] = Unidom::Common::NULL_UUID
attributes[:certificator_type] = ''
end
self.certification_is(certification).certificated_is(certificated).valid_at(now: opened_at).alive.first_or_create! attributes
end
|