Permalink
Browse files

Merge pull request #56 from glenngillen/master

Lazy evaluate database URL
  • Loading branch information...
♠ ace hacker
♠ ace hacker committed Apr 11, 2012
2 parents 6057420 + 2629f2a commit 0ac05e53ce977248a2b2c1765b10c2d90856ef3f
Showing with 5 additions and 6 deletions.
  1. +0 −5 lib/queue_classic.rb
  2. +5 −1 lib/queue_classic/conn.rb
View
@@ -18,11 +18,6 @@ module QC
SqlFunctions = File.join(QC::Root, "/sql/ddl.sql")
DropSqlFunctions = File.join(QC::Root, "/sql/drop_ddl.sql")
- DB_URL =
- ENV["QC_DATABASE_URL"] ||
- ENV["DATABASE_URL"] ||
- raise(ArgumentError, "missing QC_DATABASE_URL or DATABASE_URL")
-
# You can use the APP_NAME to query for
# postgres related process information in the
# pg_stat_activity table. Don't set this unless
@@ -84,7 +84,11 @@ def connect
end
def db_url
- URI.parse(DB_URL)
+ return @db_url if @db_url
+ url = ENV["QC_DATABASE_URL"] ||
+ ENV["DATABASE_URL"] ||
+ raise(ArgumentError, "missing QC_DATABASE_URL or DATABASE_URL")
+ @db_url = URI.parse(url)
end
def log(msg)

0 comments on commit 0ac05e5

Please sign in to comment.