Skip to content

Commit

Permalink
fix to check boolean value
Browse files Browse the repository at this point in the history
  • Loading branch information
byplayer committed Mar 14, 2012
1 parent 1a7bb27 commit 42bb183
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ext/leveldb/leveldb.cc
Expand Up @@ -85,11 +85,6 @@ static void db_options_free(bound_db_options* options) {
delete options;
}

static bool hash_val_test(VALUE h, VALUE key) {
VALUE v = rb_hash_aref(h, key);
return RTEST(v);
}

static void set_db_option(VALUE o_options, VALUE opts) {
if(!NIL_P(o_options)) {
Check_Type(opts, T_HASH);
Expand All @@ -98,12 +93,16 @@ static void set_db_option(VALUE o_options, VALUE opts) {
Data_Get_Struct(o_options, bound_db_options, db_options);
leveldb::Options* options = db_options->options;

if(hash_val_test(opts, k_create_if_missing)) {
if(rb_hash_aref(opts, k_create_if_missing) == Qtrue) {
options->create_if_missing = true;
} else {
options->create_if_missing = false;
}

if(hash_val_test(opts, k_error_if_exists)) {
if(rb_hash_aref(opts, k_error_if_exists) == Qtrue) {
options->error_if_exists = true;
} else {
options->error_if_exists = false;
}

VALUE v;
Expand Down

0 comments on commit 42bb183

Please sign in to comment.