Method: Fb::Connection#transaction
- Defined in:
- ext/fb/fb_ext.c
#transaction(options) ⇒ true #transaction(options) { ... } ⇒ Object
Start a transaction for this connection.
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 |
# File 'ext/fb/fb_ext.c', line 967
static VALUE connection_transaction(int argc, VALUE *argv, VALUE self)
{
struct FbConnection *fb_connection;
VALUE opt = Qnil;
rb_scan_args(argc, argv, "01", &opt);
Data_Get_Struct(self, struct FbConnection, fb_connection);
fb_connection_transaction_start(fb_connection, opt);
if (rb_block_given_p()) {
int state;
VALUE result = rb_protect(rb_yield, 0, &state);
if (state) {
fb_connection_rollback(fb_connection);
return rb_funcall(rb_mKernel, rb_intern("raise"), 0);
} else {
fb_connection_commit(fb_connection);
return result;
}
} else {
return Qtrue;
}
}
|