def parse_yml_for id, reload = false
db_object = reload ? (self.find(id) rescue nil) : @db_objects.select{|o| o.id == id}.first
if db_object
raise "There is already a #{db_object.class} with id #{db_object.id} in the database." unless db_object.has_alter_ego?
if db_object.alter_ego.state == 'default'
assign_attributes db_object, @yml[id]
db_object.on_seed(@yml[id])
db_object.save_without_alter_ego
end
else
alter_ego = AlterEgo.find_by_alter_ego_object_id_and_alter_ego_object_type(id, self.name)
return if alter_ego.try(:state) == "destroyed"
db_object = self.new
db_object.id = id
assign_attributes db_object, @yml[id]
db_object.build_alter_ego
db_object.alter_ego.state = 'default'
db_object.on_seed(@yml[id])
db_object.save_without_alter_ego
end
end