acts_as_partitionable 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/init.rb +1 -0
- data/lib/acts_as_partitionable.rb +6 -5
- data/lib/connection_pool.rb +5 -5
- metadata +4 -3
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_dependency 'acts_as_partitionable'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# CONFIDENTIAL AND PROPRIETARY. © 2007 Revolution Health Group LLC. All rights reserved.
|
2
|
-
|
2
|
+
|
3
|
+
require_dependency 'connection_pool'
|
4
|
+
|
3
5
|
module Acts
|
4
6
|
module Partitionable
|
5
7
|
|
@@ -8,10 +10,6 @@ module Acts
|
|
8
10
|
end
|
9
11
|
|
10
12
|
module ClassMethods
|
11
|
-
def acts_as_partitionable?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
13
|
# Readonly Simple Sample:
|
16
14
|
# class User
|
17
15
|
# acts_as_partitionable :access => :readonly, :db_config => ...
|
@@ -68,6 +66,9 @@ module Acts
|
|
68
66
|
return #{partition_db_klass}.module_eval(&block) if block_given?
|
69
67
|
#{partition_db_klass}
|
70
68
|
end
|
69
|
+
def self.acts_as_partitionable?
|
70
|
+
true
|
71
|
+
end
|
71
72
|
PART_PROC_END
|
72
73
|
end # acts_as_partitionable
|
73
74
|
|
data/lib/connection_pool.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# CONFIDENTIAL AND PROPRIETARY. © 2007 Revolution Health Group LLC. All rights reserved.
|
2
|
-
# This source code may not be disclosed to others, used or reproduced without the written permission of Revolution Health Group.
|
3
2
|
module ActiveRecord
|
4
3
|
class Base
|
5
4
|
class << self
|
@@ -40,11 +39,15 @@ module ActiveRecord
|
|
40
39
|
@partitionable_adapter_methods ||= []
|
41
40
|
if not @partitionable_adapter_methods.include?(spec.adapter_method.to_s)
|
42
41
|
@partitionable_adapter_methods << (spec.adapter_method.to_s)
|
42
|
+
|
43
43
|
self.class_eval <<-REUSE_END
|
44
|
+
class << self
|
45
|
+
alias_method :ar_#{spec.adapter_method}, :#{spec.adapter_method}
|
46
|
+
end
|
44
47
|
def self.#{spec.adapter_method}(config)
|
45
48
|
conn_key = config.to_s
|
46
49
|
if not pooled_connections.key?(conn_key)
|
47
|
-
pooled_connections[conn_key] = { :connection =>
|
50
|
+
pooled_connections[conn_key] = { :connection => ar_#{spec.adapter_method}(config), :count => 1 }
|
48
51
|
elsif pooled_connections[conn_key] != nil
|
49
52
|
pooled_connections[conn_key][:count] += 1
|
50
53
|
end
|
@@ -59,6 +62,3 @@ module ActiveRecord
|
|
59
62
|
end # Pool
|
60
63
|
end # Connection
|
61
64
|
|
62
|
-
#ActiveRecord::Base.send :include, Connection::Pool
|
63
|
-
#ActiveRecord::Base.extend Connection::Pool::ConnectionReuseMethods
|
64
|
-
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: acts_as_partitionable
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-04-
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2007-04-20 00:00:00 -04:00
|
8
8
|
summary: acts_as_partitionable allows one to use multiple DBs to partition data for models
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -12,7 +12,7 @@ email: rails-trunk@revolution.com
|
|
12
12
|
homepage:
|
13
13
|
rubyforge_project:
|
14
14
|
description:
|
15
|
-
autorequire:
|
15
|
+
autorequire: acts_as_partitionable.rb
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: false
|
@@ -31,6 +31,7 @@ authors:
|
|
31
31
|
files:
|
32
32
|
- lib/acts_as_partitionable.rb
|
33
33
|
- lib/connection_pool.rb
|
34
|
+
- init.rb
|
34
35
|
- README
|
35
36
|
- MIT-LICENSE
|
36
37
|
test_files: []
|