lib/rest/rest.rb
# Used to connect to the database
Used to connect to the database
Used to connect to the database
def connect
      first_tentative = true
      begin
	database =  ActiveOrient.database
        logger.progname = 'OrientDB#Connect'
        r = @res["/connect/#{database}"].get
        if r.code == 204
  	      logger.info{"Connected to database #{database}"}
  	      true
  	    else
  	      logger.error{"Connection to database #{database} could NOT be established"}
  	      nil
  	    end
      rescue RestClient::Unauthorized => e
        if first_tentative
  	      logger.info{"Database #{database} NOT present --> creating"}
  	      first_tentative = false
  	      create_database database: database
  	      retry
        else
  	      Kernel.exit
        end
      end
    end
def connect first_tentative = true begin database = ActiveOrient . database logger . progname = 'OrientDB#Connect' r = @res [ "/connect/#{database}" ] . get if r . code == 204 logger . info { "Connected to database #{database}" } true else logger . error { "Connection to database #{database} could NOT be established" } nil end rescue RestClient :: Unauthorized => e if first_tentative logger . info { "Database #{database} NOT present --> creating" } first_tentative = false create_database database : database retry else Kernel . exit end end end
Used to connect to the database
Used to connect to the database