def create(resources)
name = self.name
resources.each do |resource|
model = resource.model
serial = model.serial(name)
attributes = resource.dirty_attributes
properties = []
bind_values = []
model.properties(name).each do |property|
next unless attributes.key?(property)
bind_value = attributes[property]
next if bind_value.nil? && (property.serial? || !property.default?)
if property.equal?(serial)
serial = nil
end
properties << property
bind_values << bind_value
end
statement = insert_statement(model, properties, serial)
result = execute(statement, *bind_values)
if result.affected_rows == 1 && serial
serial.set!(resource, result.insert_id)
end
end
end