/*
 * Create a new connection to the FAM daemon.
 *
 * Aliases:
 *   Fam::Connection.open2
 *
 * Examples:
 *   # connect and tell FAM the application is named 'foo'
 *   fam = Fam::Connection.open 'foo'
 *
 *   # just connect
 *   fam = Fam::Connection.open
 *
 *   # connect and close automatically
 *   Fam::Connection.open('foo') {|fam| ... }
 *
 */
static VALUE
fam_conn_s_open(int argc, VALUE *argv, VALUE klass)
{
  VALUE self = rb_class_new_instance(argc, argv, klass);

  if (rb_block_given_p()) {
    return rb_ensure(rb_yield, self, conn_close, self);
  }

  return self;
}