Permalink
Browse files

Fix connection issue where connected? caused a connection

to be established.
  • Loading branch information...
1 parent 64b7cc9 commit 6a366ac0ba1212e5223a8b002587182e17c06504 @mperham mperham committed Nov 22, 2008
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/data_fabric.rb
View
7 lib/data_fabric.rb
@@ -83,6 +83,11 @@ def self.active_shard(group)
raise ArgumentError, "No active shard for #{group}" unless shard
end
end
+
+ def self.shard_active_for?(group)
+ return true unless group
+ Thread.current[:shards] and Thread.current[:shards][group.to_s]
+ end
def self.included(model)
# Wire up ActiveRecord::Base
@@ -203,7 +208,7 @@ def connection
end
def connected?
- cached_connections[connection_name]
+ DataFabric.shard_active_for?(@shard_group) and cached_connections[connection_name]
end
def set_role(role)

0 comments on commit 6a366ac

Please sign in to comment.