Class: Appsignal::Extension::Data Private

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/extension.rb,
ext/appsignal_extension.c

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Data equality



515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'ext/appsignal_extension.c', line 515

static VALUE data_equal(VALUE self, VALUE other) {
  appsignal_data_t* data;
  appsignal_data_t* other_data;

  if (TYPE(other) != RUBY_T_DATA) {
    return Qfalse;
  }

  Data_Get_Struct(self, appsignal_data_t, data);
  Data_Get_Struct(other, appsignal_data_t, other_data);

  if (appsignal_data_equal(data, other_data) == 1) {
    return Qtrue;
  } else {
    return Qfalse;
  }
}

#append_boolean(value) ⇒ Object



475
476
477
478
479
480
481
482
483
484
485
486
# File 'ext/appsignal_extension.c', line 475

static VALUE data_append_boolean(VALUE self, VALUE value) {
  appsignal_data_t* data;

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_array_append_boolean(
    data,
    RTEST(value)
 );

  return Qnil;
}

#append_data(value) ⇒ Object



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'ext/appsignal_extension.c', line 498

static VALUE data_append_data(VALUE self, VALUE value) {
  appsignal_data_t* data;
  appsignal_data_t* value_data;

  Check_Type(value, RUBY_T_DATA);

  Data_Get_Struct(self, appsignal_data_t, data);
  Data_Get_Struct(value, appsignal_data_t, value_data);

  appsignal_data_array_append_data(
    data,
    value_data
  );

  return Qnil;
}

#append_float(value) ⇒ Object



460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'ext/appsignal_extension.c', line 460

static VALUE data_append_float(VALUE self, VALUE value) {
  appsignal_data_t* data;

  Check_Type(value, T_FLOAT);

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_array_append_float(
    data,
    NUM2DBL(value)
 );

  return Qnil;
}

#append_integer(value) ⇒ Object



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'ext/appsignal_extension.c', line 442

static VALUE data_append_integer(VALUE self, VALUE value) {
  appsignal_data_t* data;
  VALUE value_type = TYPE(value);

  if (value_type != T_FIXNUM && value_type != T_BIGNUM) {
    rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)", rb_obj_classname(value));
  }

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_array_append_integer(
    data,
    NUM2LONG(value)
 );

  return Qnil;
}

#append_nil(value) ⇒ Object



488
489
490
491
492
493
494
495
496
# File 'ext/appsignal_extension.c', line 488

static VALUE data_append_nil(VALUE self, VALUE value) {
  appsignal_data_t* data;

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_array_append_null(data);

  return Qnil;
}

#append_string(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add content to a data array



427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'ext/appsignal_extension.c', line 427

static VALUE data_append_string(VALUE self, VALUE value) {
  appsignal_data_t* data;

  Check_Type(value, T_STRING);

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_array_append_string(
    data,
    make_appsignal_string(value)
  );

  return Qnil;
}

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
# File 'lib/appsignal/extension.rb', line 60

def inspect
  "#<#{self.class.name}:#{object_id} #{self}>"
end

#set_boolean(key, value) ⇒ Object



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'ext/appsignal_extension.c', line 377

static VALUE data_set_boolean(VALUE self, VALUE key, VALUE value) {
  appsignal_data_t* data;

  Check_Type(key, T_STRING);

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_map_set_boolean(
    data,
    make_appsignal_string(key),
    RTEST(value)
  );

  return Qnil;
}

#set_data(key, value) ⇒ Object



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'ext/appsignal_extension.c', line 408

static VALUE data_set_data(VALUE self, VALUE key, VALUE value) {
  appsignal_data_t* data;
  appsignal_data_t* value_data;

  Check_Type(key, T_STRING);
  Check_Type(value, RUBY_T_DATA);

  Data_Get_Struct(self, appsignal_data_t, data);
  Data_Get_Struct(value, appsignal_data_t, value_data);

  appsignal_data_map_set_data(
    data,
    make_appsignal_string(key),
    value_data
  );

  return Qnil;
}

#set_float(key, value) ⇒ Object



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'ext/appsignal_extension.c', line 360

static VALUE data_set_float(VALUE self, VALUE key, VALUE value) {
  appsignal_data_t* data;

  Check_Type(key, T_STRING);
  Check_Type(value, T_FLOAT);

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_map_set_float(
    data,
    make_appsignal_string(key),
    NUM2DBL(value)
  );

  return Qnil;
}

#set_integer(key, value) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'ext/appsignal_extension.c', line 340

static VALUE data_set_integer(VALUE self, VALUE key, VALUE value) {
  appsignal_data_t* data;
  VALUE value_type = TYPE(value);

  Check_Type(key, T_STRING);
  if (value_type != T_FIXNUM && value_type != T_BIGNUM) {
    rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)", rb_obj_classname(value));
  }

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_map_set_integer(
    data,
    make_appsignal_string(key),
    NUM2LONG(value)
  );

  return Qnil;
}

#set_nil(key) ⇒ Object



393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'ext/appsignal_extension.c', line 393

static VALUE data_set_nil(VALUE self, VALUE key) {
  appsignal_data_t* data;

  Check_Type(key, T_STRING);

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_map_set_null(
    data,
    make_appsignal_string(key)
  );

  return Qnil;
}

#set_string(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add content to a data map



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'ext/appsignal_extension.c', line 323

static VALUE data_set_string(VALUE self, VALUE key, VALUE value) {
  appsignal_data_t* data;

  Check_Type(key, T_STRING);
  Check_Type(value, T_STRING);

  Data_Get_Struct(self, appsignal_data_t, data);

  appsignal_data_map_set_string(
    data,
    make_appsignal_string(key),
    make_appsignal_string(value)
  );

  return Qnil;
}

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get JSON content of a data



533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'ext/appsignal_extension.c', line 533

static VALUE data_to_s(VALUE self) {
  appsignal_data_t* data;
  appsignal_string_t json;

  Data_Get_Struct(self, appsignal_data_t, data);

  json = appsignal_data_to_json(data);

  if (json.len == 0) {
    return Qnil;
  } else {
    return make_ruby_string(json);
  }
}