73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/active_archiver/active_record_ext.rb', line 73
def import(hash, validate: false)
hash = hash.with_indifferent_access
obj = self.find_or_initialize_by(id: hash["attributes"]["id"])
obj.attributes = hash["attributes"]
obj = restore_image(obj, hash)
obj.save(validate: validate)
hash["associations"].each do |r|
r_obj = Object.const_get(r["model_name"]).find_or_initialize_by(id: r["attributes"]["id"])
r_obj.attributes = r["attributes"]
r_obj = restore_image(r_obj, r)
r_obj.save(validate: validate)
end
end
|