summaryrefslogtreecommitdiff
path: root/ext/sdbm/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sdbm/init.c')
-rw-r--r--ext/sdbm/init.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 07e5567329e..c8883c9f8da 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -62,6 +62,21 @@ fsdbm_close(obj)
return Qnil;
}
+static VALUE
+fsdbm_closed(obj)
+ VALUE obj;
+{
+ struct dbmdata *dbmp;
+
+ Data_Get_Struct(obj, struct dbmdata, dbmp);
+ if (dbmp == 0)
+ return Qtrue;
+ if (dbmp->di_dbm == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
static VALUE fsdbm_alloc _((VALUE));
static VALUE
fsdbm_alloc(klass)
@@ -700,6 +715,7 @@ Init_sdbm()
rb_define_method(rb_cDBM, "initialize", fsdbm_initialize, -1);
rb_define_method(rb_cDBM, "close", fsdbm_close, 0);
+ rb_define_method(rb_cDBM, "closed?", fsdbm_closed, 0);
rb_define_method(rb_cDBM, "[]", fsdbm_aref, 1);
rb_define_method(rb_cDBM, "fetch", fsdbm_fetch_m, -1);
rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2);