[ap4r-devel] [251] trunk/ap4r/lib/ap4r/message_store_ext.rb: Refactoring: judgement of postgres library load.

kato-k at rubyforge.org kato-k at rubyforge.org
Fri Aug 10 02:46:34 EDT 2007


Revision: 251
Author:   kato-k
Date:     2007-08-10 02:46:33 -0400 (Fri, 10 Aug 2007)

Log Message:
-----------
Refactoring: judgement of postgres library load.

Modified Paths:
--------------
    trunk/ap4r/lib/ap4r/message_store_ext.rb

Modified: trunk/ap4r/lib/ap4r/message_store_ext.rb
===================================================================
--- trunk/ap4r/lib/ap4r/message_store_ext.rb	2007-08-10 04:30:04 UTC (rev 250)
+++ trunk/ap4r/lib/ap4r/message_store_ext.rb	2007-08-10 06:46:33 UTC (rev 251)
@@ -192,12 +192,11 @@
         end
 
         def connection
-#          Thread.current[THREAD_CURRENT_PGSQL] ||= ::PostgresPR::Connection.new @config[:host], @config[:username], @config[:password], at config[:database], @config[:port], @config[:socket]
-
           Thread.current[THREAD_CURRENT_PGSQL] ||= 
-            if $:.any?{ |e| e.include?('postgres') and not e.include?('postgres-pr') }
+            # PGconn is overriding in this file, so is defined regardless of 'postgres' LoadError.
+            if Object.const_defined? :PGError
               ::PGconn.connect @config[:host], @config[:port], @config[:options], @config[:tty], @config[:database], @config[:username], @config[:password]              
-            elsif $:.any?{ |e| e.include?('postgres-pr')}
+            elsif Object.const_defined? :PostgresPR
               ::PostgresPR::Connection.new @config[:database], @config[:username], @config[:password], @config[:uri]
             end
 




More information about the ap4r-devel mailing list