Method: Extralite::Changeset#each
- Defined in:
- ext/extralite/changeset.c
#each ⇒ Extralite::Changeset
Iterates through the changeset, providing each change to the given block. Each change entry is an array containing the operation (:insert / :update / :delete), the table name, an array containing the old values, and an array containing the new values.
changeset.each do |(op, table, old_values, new_values)|
...
end
308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'ext/extralite/changeset.c', line 308 VALUE Changeset_each(VALUE self) { Changeset_t *changeset = self_to_changeset(self); verify_changeset(changeset); struct each_ctx ctx = { .iter = NULL }; int rc = sqlite3changeset_start(&ctx.iter, changeset->changeset_len, changeset->changeset_ptr); if (rc!=SQLITE_OK) rb_raise(cError, "Error while starting iterator: %s", sqlite3_errstr(rc)); rb_ensure(SAFE(safe_each), (VALUE)&ctx, SAFE(cleanup_iter), (VALUE)&ctx); return self; } |