ar-octopus 0.2.1 → 0.2.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/README.mkdn +3 -2
- data/Rakefile +1 -1
- data/ar-octopus.gemspec +2 -2
- data/lib/octopus/model.rb +5 -0
- data/spec/database_models.rb +1 -1
- data/spec/octopus/model_spec.rb +1 -2
- metadata +4 -4
data/README.mkdn
CHANGED
@@ -127,11 +127,12 @@ Sometimes, when a connection isn't used for much time, this will makes ActiveRec
|
|
127
127
|
This will tell Octopus to verify the connection before sending the query.
|
128
128
|
|
129
129
|
## Mixing Octopus with the Rails multiple database model
|
130
|
-
|
130
|
+
If you want to set a custom connection to a specific model, use this syntax:
|
131
131
|
|
132
132
|
#This class sets its own connection
|
133
|
+
# establish_connection will not work, use octopus_establish_connection instead.
|
133
134
|
class CustomConnection < ActiveRecord::Base
|
134
|
-
|
135
|
+
octopus_establish_connection(:adapter => "mysql", :database => "octopus_shard2")
|
135
136
|
end
|
136
137
|
|
137
138
|
## Contributing with Octopus
|
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.2.
|
40
|
+
gem.version = "0.2.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.2.
|
8
|
+
s.version = "0.2.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
|
+
s.date = %q{2010-11-03}
|
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/model.rb
CHANGED
@@ -85,6 +85,11 @@ module Octopus::Model
|
|
85
85
|
def sharded_model()
|
86
86
|
write_inheritable_attribute(:sharded, true)
|
87
87
|
end
|
88
|
+
|
89
|
+
def octopus_establish_connection(spec = nil)
|
90
|
+
write_inheritable_attribute(:establish_connection, true)
|
91
|
+
establish_connection(spec)
|
92
|
+
end
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
data/spec/database_models.rb
CHANGED
@@ -21,7 +21,7 @@ end
|
|
21
21
|
|
22
22
|
#This class sets its own connection
|
23
23
|
class CustomConnection < ActiveRecord::Base
|
24
|
-
|
24
|
+
octopus_establish_connection(:adapter => "mysql", :database => "octopus_shard2", :username => "root", :password => "")
|
25
25
|
end
|
26
26
|
|
27
27
|
#This items belongs to a client
|
data/spec/octopus/model_spec.rb
CHANGED
@@ -173,8 +173,7 @@ describe Octopus::Model do
|
|
173
173
|
|
174
174
|
describe "AR basic methods" do
|
175
175
|
it "establish_connection" do
|
176
|
-
|
177
|
-
# CustomConnection.connection.current_database.should == "octopus_shard2"
|
176
|
+
CustomConnection.connection.current_database.should == "octopus_shard2"
|
178
177
|
end
|
179
178
|
|
180
179
|
it "increment" do
|
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.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-
|
19
|
+
date: 2010-11-03 00:00:00 -02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|