read_from_slave 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/read_from_slave.rb +4 -4
- data/test/helper.rb +1 -1
- metadata +17 -4
data/lib/read_from_slave.rb
CHANGED
@@ -128,9 +128,9 @@ module ReadFromSlave
|
|
128
128
|
|
129
129
|
@@slave_models = {}
|
130
130
|
|
131
|
-
def find_by_sql_with_read_from_slave(
|
131
|
+
def find_by_sql_with_read_from_slave(*find_args)
|
132
132
|
Thread.current[:read_from_slave] = (Thread.current[:read_from_slave] != :reload)
|
133
|
-
find_by_sql_without_read_from_slave(
|
133
|
+
find_by_sql_without_read_from_slave(*find_args)
|
134
134
|
ensure
|
135
135
|
Thread.current[:read_from_slave] = false
|
136
136
|
end
|
@@ -149,7 +149,7 @@ module ReadFromSlave
|
|
149
149
|
if Thread.current[:read_from_slave] && normal_connection.open_transactions == 0
|
150
150
|
slaves.each do |slave_name, slave_config|
|
151
151
|
if Thread.current[:"with_#{slave_name}_count"].to_i > 0
|
152
|
-
Thread.current[:read_from_slave_uses] = slave_name # for testing use
|
152
|
+
Thread.current[:read_from_slave_uses] = slave_name.to_sym # for testing use
|
153
153
|
return slave_connection(slave_config)
|
154
154
|
end
|
155
155
|
end
|
@@ -204,7 +204,7 @@ module ReadFromSlave
|
|
204
204
|
|
205
205
|
# Returns the first slave defined in database.yml which will be used by default for reads
|
206
206
|
def primary_slave_config
|
207
|
-
slaves[primary_slave_name]
|
207
|
+
slaves.symbolize_keys[primary_slave_name]
|
208
208
|
end
|
209
209
|
|
210
210
|
# Returns the first slave defined in database.yml which will be used by default for reads
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: read_from_slave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Stephen Sykes
|
@@ -10,7 +15,8 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-11-27 00:00:00 +02:00
|
19
|
+
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
16
22
|
description: Read_from_slave for Rails enables database reads from a slave database, while writes continue to go to the master
|
@@ -36,6 +42,7 @@ files:
|
|
36
42
|
- test/schema/schema.rb
|
37
43
|
- test/setup.rb
|
38
44
|
- test/test.rb
|
45
|
+
has_rdoc: true
|
39
46
|
homepage: http://github.com/sdsykes/read_from_slave
|
40
47
|
licenses: []
|
41
48
|
|
@@ -49,17 +56,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
56
|
requirements:
|
50
57
|
- - ">="
|
51
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
52
62
|
version: "0"
|
53
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
64
|
none: false
|
55
65
|
requirements:
|
56
66
|
- - ">="
|
57
67
|
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
58
71
|
version: "0"
|
59
72
|
requirements: []
|
60
73
|
|
61
74
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.
|
75
|
+
rubygems_version: 1.3.7
|
63
76
|
signing_key:
|
64
77
|
specification_version: 3
|
65
78
|
summary: Read_from_slave - Utilise your slave databases with rails
|