Class: Couchbase::Result

Inherits:
Object
  • Object
show all
Defined in:
ext/couchbase_ext/couchbase_ext.c,
ext/couchbase_ext/couchbase_ext.c

Overview

The object which yielded to asynchronous callbacks

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Fixnum) cas (readonly)

Returns:

  • (Fixnum)

- (Couchbase::Error::Base) error (readonly)

- (Fixnum) flags (readonly)

Returns:

  • (Fixnum)

- (String) key (readonly)

Returns:

  • (String)

- (String) node (readonly)

Returns:

  • (String)

- (Symbol) operation (readonly)

Returns:

  • (Symbol)

- (String) value (readonly)

Returns:

  • (String)

Instance Method Details

- (String) inspect

Returns a string containing a human-readable representation of the Result.

Returns:

  • (String)


3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
# File 'ext/couchbase_ext/couchbase_ext.c', line 3170

static VALUE
cb_result_inspect(VALUE self)
{
    VALUE str, attr, error;
    char buf[100];

    str = rb_str_buf_new2("#<");
    rb_str_buf_cat2(str, rb_obj_classname(self));
    snprintf(buf, 100, ":%p", (void *)self);
    rb_str_buf_cat2(str, buf);

    attr = rb_ivar_get(self, id_iv_error);
    if (RTEST(attr)) {
        error = rb_ivar_get(attr, id_iv_error);
    } else {
        error = INT2FIX(0);
    }
    rb_str_buf_cat2(str, " error=0x");
    rb_str_append(str, rb_funcall(error, id_to_s, 1, INT2FIX(16)));

    attr = rb_ivar_get(self, id_iv_key);
    if (RTEST(attr)) {
        rb_str_buf_cat2(str, " key=");
        rb_str_append(str, rb_inspect(attr));
    }

    attr = rb_ivar_get(self, id_iv_cas);
    if (RTEST(attr)) {
        rb_str_buf_cat2(str, " cas=");
        rb_str_append(str, rb_inspect(attr));
    }

    attr = rb_ivar_get(self, id_iv_flags);
    if (RTEST(attr)) {
        rb_str_buf_cat2(str, " flags=0x");
        rb_str_append(str, rb_funcall(attr, id_to_s, 1, INT2FIX(16)));
    }

    attr = rb_ivar_get(self, id_iv_node);
    if (RTEST(attr)) {
        rb_str_buf_cat2(str, " node=");
        rb_str_append(str, rb_inspect(attr));
    }
    rb_str_buf_cat2(str, ">");

    return str;
}

- (Boolean) success?

Check if result of operation was successful.

Returns:

  • (Boolean)

    false if there is an error object attached, false otherwise.

  • (Boolean)


3159
3160
3161
3162
3163
# File 'ext/couchbase_ext/couchbase_ext.c', line 3159

static VALUE
cb_result_success_p(VALUE self)
{
    return RTEST(rb_ivar_get(self, id_iv_error)) ? Qfalse : Qtrue;
}