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.

Direct Known Subclasses

MockData

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



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'ext/appsignal_extension.c', line 561

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

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

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);
  TypedData_Get_Struct(other, appsignal_data_t, &data_data_type, other_data);

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

#append_boolean(value) ⇒ Object



522
523
524
525
526
527
528
529
530
531
532
533
# File 'ext/appsignal_extension.c', line 522

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

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

  appsignal_data_array_append_boolean(
    data,
    RTEST(value)
 );

  return Qnil;
}

#append_data(value) ⇒ Object



545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'ext/appsignal_extension.c', line 545

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

  value_data = rb_check_typeddata(value, &data_data_type);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

  appsignal_data_array_append_data(
    data,
    value_data
  );

  return Qnil;
}

#append_float(value) ⇒ Object



507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'ext/appsignal_extension.c', line 507

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

  Check_Type(value, T_FLOAT);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

  appsignal_data_array_append_float(
    data,
    NUM2DBL(value)
 );

  return Qnil;
}

#append_integer(value) ⇒ Object



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'ext/appsignal_extension.c', line 489

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));
  }

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

  appsignal_data_array_append_integer(
    data,
    NUM2LONG(value)
 );

  return Qnil;
}

#append_nilObject



535
536
537
538
539
540
541
542
543
# File 'ext/appsignal_extension.c', line 535

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

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, 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



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

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

  Check_Type(value, T_STRING);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, 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.



73
74
75
# File 'lib/appsignal/extension.rb', line 73

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

#set_boolean(key, value) ⇒ Object



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

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

  Check_Type(key, T_STRING);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

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

  return Qnil;
}

#set_data(key, value) ⇒ Object



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

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);
  value_data = rb_check_typeddata(value, &data_data_type);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

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

  return Qnil;
}

#set_float(key, value) ⇒ Object



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

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);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

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

  return Qnil;
}

#set_integer(key, value) ⇒ Object



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

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));
  }

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

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

  return Qnil;
}

#set_nil(key) ⇒ Object



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

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

  Check_Type(key, T_STRING);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, 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



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'ext/appsignal_extension.c', line 371

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);

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, 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



579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'ext/appsignal_extension.c', line 579

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

  TypedData_Get_Struct(self, appsignal_data_t, &data_data_type, data);

  json = appsignal_data_to_json(data);

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