ext/iodine/iodine_pubsub.c
// clang-format off
/**
Sends a Redis command. Accepts an optional block that will recieve the response.

i.e.:

    REDIS_URL = "redis://redis:password@localhost:6379/"
    redis = Iodine::PubSub::Redis.new(REDIS_URL, ping: 50) #pings every 50 seconds
    Iodine::PubSub.default = redis
    redis.cmd("KEYS", "*") {|result| p result
}


*/
clang-format off
Sends a Redis command. Accepts an optional block that will recieve the response.




clang - format off Sends a Redis command . Accepts an optional block that will recieve the response .
static VALUE iodine_pubsub_redis_cmd(int argc, VALUE *argv, VALUE self) {
  if (argc <= 0) {
    rb_raise(rb_eArgError, "Iodine::PubSub::Redis#cmd(command, ...) is missing "
                           "the required command argument.");
  }
  iodine_pubsub_s *e = iodine_pubsub_CData(self);
  if (!e || !e->engine || e->engine == &e->do_not_touch) {
    rb_raise(rb_eTypeError,
             "Iodine::PubSub::Redis internal error - obsolete object?");
  }
  VALUE block = Qnil;
  if (rb_block_given_p()) {
    block = IodineStore.add(rb_block_proc());
  }
  FIOBJ data = fiobj_ary_new2((size_t)argc);
  for (int i = 0; i < argc; ++i) {
    switch (TYPE(argv[i])) {
    case T_SYMBOL:
      argv[i] = rb_sym2str(argv[i]);
    case T_STRING:
      fiobj_ary_push(data,
                     fiobj_str_new(RSTRING_PTR(argv[i]), RSTRING_LEN(argv[i])));
      break;
    case T_FIXNUM:
      fiobj_ary_push(data, fiobj_num_new(NUM2SSIZET(argv[i])));
      break;
    case T_FLOAT:
      fiobj_ary_push(data, fiobj_float_new(rb_float_value(argv[i])));
      break;
    case T_NIL:
      fiobj_ary_push(data, fiobj_null());
      break;
    case T_TRUE:
      fiobj_ary_push(data, fiobj_true());
      break;
    case T_FALSE:
      fiobj_ary_push(data, fiobj_false());
      break;
    default:
      goto wrong_type;
    }
  }
  if (redis_engine_send(e->engine, data, iodine_pubsub_redis_callback,
                        (void *)block)) {
    iodine_pubsub_redis_callback(e->engine, fiobj_null(), (void *)block);
  }
  fiobj_free(data);
  return self;
wrong_type:
  fiobj_free(data);
  rb_raise(rb_eArgError,
           "only String, Number (with limits), Symbol, true, false and nil "
           "arguments can be used.");
}
static VALUE iodine_pubsub_redis_cmd ( int argc , VALUE * argv , VALUE self ) { if ( argc <= 0 ) { rb_raise ( rb_eArgError , " " " " ) ; } iodine_pubsub_s * e = iodine_pubsub_CData ( self ) ; if ( ! e || ! e -> engine || e -> engine == & e -> do_not_touch ) { rb_raise ( rb_eTypeError , " " ) ; } VALUE block = Qnil ; if ( rb_block_given_p ( ) ) { block = IodineStore . add ( rb_block_proc ( ) ) ; } FIOBJ data = fiobj_ary_new2 ( ( size_t ) argc ) ; for ( int i = 0 ; i < argc ; ++ i ) { switch ( TYPE ( argv [ i ] ) ) { case T_SYMBOL : argv [ i ] = rb_sym2str ( argv [ i ] ) ; case T_STRING : fiobj_ary_push ( data , fiobj_str_new ( RSTRING_PTR ( argv [ i ] ) , RSTRING_LEN ( argv [ i ] ) ) ) ; break ; case T_FIXNUM : fiobj_ary_push ( data , fiobj_num_new ( NUM2SSIZET ( argv [ i ] ) ) ) ; break ; case T_FLOAT : fiobj_ary_push ( data , fiobj_float_new ( rb_float_value ( argv [ i ] ) ) ) ; break ; case T_NIL : fiobj_ary_push ( data , fiobj_null ( ) ) ; break ; case T_TRUE : fiobj_ary_push ( data , fiobj_true ( ) ) ; break ; case T_FALSE : fiobj_ary_push ( data , fiobj_false ( ) ) ; break ; default : goto wrong_type ; } } if ( redis_engine_send ( e -> engine , data , iodine_pubsub_redis_callback , ( void * ) block ) ) { iodine_pubsub_redis_callback ( e -> engine , fiobj_null ( ) , ( void * ) block ) ; } fiobj_free ( data ) ; return self ; wrong_type : fiobj_free ( data ) ; rb_raise ( rb_eArgError , " " " " ) ; }
clang-format off
Sends a Redis command.
clang - format off Sends a Redis command .
// clang-format on /* overflow */