db-charmer 1.6.18 → 1.6.19

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,4 @@
1
- 1.6.17/1.6.18 (2011-04-25):
1
+ 1.6.17-19 (2011-04-25):
2
2
 
3
3
  Bugfixes: Do not touch database for sharded models until we really need to. Before 1.6.17
4
4
  if a database server was dead and there were any other connection issues, class loading
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.18
1
+ 1.6.19
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{db-charmer}
8
- s.version = "1.6.18"
8
+ s.version = "1.6.19"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexey Kovyrin"]
@@ -23,13 +23,14 @@ module DbCharmer
23
23
  return @real_conn if @real_conn
24
24
 
25
25
  # If sharded connection supports shards enumeration, get the first shard
26
- @real_conn = sharded_connection.shard_connections.try(:first)
26
+ conn = sharded_connection.shard_connections.try(:first)
27
27
 
28
28
  # If we do not have real connection yet, try to use the default one (if it is supported by the sharder)
29
- @real_conn ||= sharded_connection.sharder.shard_for_key(:default) if sharded_connection.support_default_shard?
29
+ conn ||= sharded_connection.sharder.shard_for_key(:default) if sharded_connection.support_default_shard?
30
30
 
31
31
  # Get connection proxy for our real connection
32
- @real_conn && coerce_to_connection_proxy(@real_conn, DbCharmer.connections_should_exist?)
32
+ return nil unless conn
33
+ @real_conn = ActiveRecord::Base.coerce_to_connection_proxy(conn, DbCharmer.connections_should_exist?)
33
34
  end
34
35
 
35
36
  def method_missing(meth, *args, &block)
@@ -39,12 +40,12 @@ module DbCharmer
39
40
  end
40
41
 
41
42
  # Fail if no connection has been established yet
42
- unless @real_conn
43
+ unless real_connection
43
44
  raise ActiveRecord::ConnectionNotEstablished, "No real connection to proxy this method to!"
44
45
  end
45
46
 
46
47
  # Proxy the call to our real connection target
47
- @real_conn.__send__(meth, *args, &block)
48
+ real_connection.__send__(meth, *args, &block)
48
49
  end
49
50
  end
50
51
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-charmer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 18
10
- version: 1.6.18
9
+ - 19
10
+ version: 1.6.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexey Kovyrin