ar-octopus 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/ar-octopus.gemspec +2 -2
- data/lib/octopus/proxy.rb +4 -3
- data/spec/octopus/model_spec.rb +20 -0
- metadata +4 -4
data/Rakefile
CHANGED
@@ -37,7 +37,7 @@ begin
|
|
37
37
|
gem.add_development_dependency "jeweler", ">= 1.4"
|
38
38
|
gem.add_development_dependency "actionpack", ">= 2.3"
|
39
39
|
gem.add_dependency('activerecord', '>= 2.3')
|
40
|
-
gem.version = "0.3.
|
40
|
+
gem.version = "0.3.2"
|
41
41
|
end
|
42
42
|
Jeweler::GemcutterTasks.new
|
43
43
|
rescue LoadError
|
data/ar-octopus.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ar-octopus}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thiago Pradi", "Mike Perham"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-14}
|
13
13
|
s.description = %q{This gem allows you to use sharded databases with ActiveRecord. this also provides a interface for replication and for running migrations with multiples shards.}
|
14
14
|
s.email = %q{tchandy@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/octopus/proxy.rb
CHANGED
@@ -89,13 +89,14 @@ class Octopus::Proxy
|
|
89
89
|
|
90
90
|
def run_queries_on_shard(shard, &block)
|
91
91
|
older_shard = self.current_shard
|
92
|
-
self.block
|
93
|
-
self.current_shard = shard
|
92
|
+
last_block = self.block
|
94
93
|
|
95
94
|
begin
|
95
|
+
self.block = true
|
96
|
+
self.current_shard = shard
|
96
97
|
yield
|
97
98
|
ensure
|
98
|
-
self.block = false
|
99
|
+
self.block = last_block || false
|
99
100
|
self.current_shard = older_shard
|
100
101
|
end
|
101
102
|
end
|
data/spec/octopus/model_spec.rb
CHANGED
@@ -271,11 +271,31 @@ describe Octopus::Model do
|
|
271
271
|
@user2.delete
|
272
272
|
lambda { User.using(:brazil).find(@user2.id) }.should raise_error(ActiveRecord::RecordNotFound)
|
273
273
|
end
|
274
|
+
|
275
|
+
it "delete within block shouldn't lose shard" do
|
276
|
+
Octopus.using(:brazil) do
|
277
|
+
@user2.delete
|
278
|
+
@user3 = User.create(:name => "User3")
|
279
|
+
|
280
|
+
User.connection.current_shard.should == :brazil
|
281
|
+
User.find(@user3.id).should == @user3
|
282
|
+
end
|
283
|
+
end
|
274
284
|
|
275
285
|
it "destroy" do
|
276
286
|
@user2.destroy
|
277
287
|
lambda { User.using(:brazil).find(@user2.id) }.should raise_error(ActiveRecord::RecordNotFound)
|
278
288
|
end
|
289
|
+
|
290
|
+
it "destroy within block shouldn't lose shard" do
|
291
|
+
Octopus.using(:brazil) do
|
292
|
+
@user2.destroy
|
293
|
+
@user3 = User.create(:name => "User3")
|
294
|
+
|
295
|
+
User.connection.current_shard.should == :brazil
|
296
|
+
User.find(@user3.id).should == @user3
|
297
|
+
end
|
298
|
+
end
|
279
299
|
end
|
280
300
|
end
|
281
301
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-octopus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thiago Pradi
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-14 00:00:00 -02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|