7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'backend/app/model/mixins/auto_generator.rb', line 7
def update_from_json(json, opts = {}, apply_nested_records = true)
self.class.properties_to_auto_generate.each do |generate_opts|
next if generate_opts[:only_if] and not generate_opts[:only_if].call(json)
if generate_opts[:only_on_create]
json[generate_opts[:property]] = self.send(generate_opts[:property])
else
next if generate_opts[:only_if_nil] and not json[generate_opts[:property]].nil?
json[generate_opts[:property]] = generate_opts[:generator].call(json)
mark_as_system_modified
end
end
super
end
|