Class: Couchbase::Result

Inherits:
Object
  • Object
show all
Defined in:
ext/couchbase_ext/couchbase_ext.c,
lib/couchbase/result.rb,
ext/couchbase_ext/couchbase_ext.c

Overview

The object which yielded to asynchronous callbacks

Since:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Result) initialize(attrs = {})

A new instance of Result



20
21
22
23
24
# File 'lib/couchbase/result.rb', line 20

def initialize(attrs = {})
  attrs.each do |k, v|
    instance_variable_set("@#{k}", v) if respond_to?(k)
  end
end

Instance Attribute Details

- (Fixnum) cas (readonly)

Returns:

  • (Fixnum)

Since:

  • 1.0.0

- (Boolean) completed (readonly) Also known as: completed?

In Bucket::CouchRequest operations used to mark the final call

Returns:

  • (Boolean)

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

Returns:

Since:

  • 1.0.0

- (Fixnum) flags (readonly)

Returns:

  • (Fixnum)

Since:

  • 1.0.0

- (Boolean) from_master (readonly) Also known as: from_master?

True if key stored on master

Returns:

  • (Boolean)

See Also:

Since:

  • 1.2.0.dp6

- (String) key (readonly)

Returns:

  • (String)

Since:

  • 1.0.0

- (String) node (readonly)

Returns:

  • (String)

Since:

  • 1.0.0

- (Symbol) operation (readonly)

Returns:

  • (Symbol)

Since:

  • 1.0.0

- (Symbol) status (readonly)

Status of the key. Possible values:

:found :Key found in cache, but not yet persisted
:persisted :Key found and persisted
:not_found :Key not found

Returns:

  • (Symbol)

See Also:

Since:

  • 1.2.0.dp6

- (Fixnum) time_to_persist (readonly) Also known as: ttp

Average time needed to persist key on the disk (zero if unavailable)

Returns:

  • (Fixnum)

See Also:

Since:

  • 1.2.0.dp6

- (Fixnum) time_to_replicate (readonly) Also known as: ttr

Average time needed to replicate key on the disk (zero if unavailable)

Returns:

  • (Fixnum)

See Also:

Since:

  • 1.2.0.dp6

- (String) value (readonly)

Returns:

  • (String)

Since:

  • 1.0.0

Instance Method Details

- (String) inspect

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

Returns:

  • (String)

Since:

  • 1.0.0



4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
# File 'ext/couchbase_ext/couchbase_ext.c', line 4029

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_operation);
    if (RTEST(attr)) {
        rb_str_buf_cat2(str, " operation=");
        rb_str_append(str, rb_inspect(attr));
    }

    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_status);
    if (RTEST(attr)) {
        rb_str_buf_cat2(str, " status=");
        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));
    }

    attr = rb_ivar_get(self, id_iv_from_master);
    if (attr != Qnil) {
        rb_str_buf_cat2(str, " from_master=");
        rb_str_append(str, rb_inspect(attr));
    }

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

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

    rb_str_buf_cat2(str, ">");

    return str;
}

- (true, ...) success?

Check if result of operation was successful.

Returns:

  • (true, false)

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

  • (Boolean)

Since:

  • 1.0.0



4016
4017
4018
4019
4020
# File 'ext/couchbase_ext/couchbase_ext.c', line 4016

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