glebpom-db-charmer 1.1.5 → 1.3.0
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 +4 -4
- data/VERSION +1 -1
- data/db-charmer.gemspec +7 -6
- data/lib/db_charmer/action_controller_extensions.rb +40 -0
- data/lib/db_charmer/finder_overrides.rb +1 -1
- data/lib/db_charmer.rb +6 -0
- metadata +7 -5
data/Rakefile
CHANGED
@@ -2,11 +2,11 @@ begin
|
|
2
2
|
require 'jeweler'
|
3
3
|
Jeweler::Tasks.new do |gemspec|
|
4
4
|
gemspec.name = 'db-charmer'
|
5
|
-
gemspec.summary = 'ActiveRecord Connections Magic'
|
5
|
+
gemspec.summary = 'ActiveRecord Connections Magic (qik.com version)'
|
6
6
|
gemspec.description = 'ActiveRecord Connections Magic (slaves, multiple connections, etc)'
|
7
|
-
gemspec.email = '
|
8
|
-
gemspec.homepage = 'http://github.com/
|
9
|
-
gemspec.authors = ['Alexey Kovyrin']
|
7
|
+
gemspec.email = 'gleb.pomykalov@qik.com'
|
8
|
+
gemspec.homepage = 'http://github.com/glebpom/db-charmer'
|
9
|
+
gemspec.authors = ['Alexey Kovyrin', 'Gleb Pomykalov']
|
10
10
|
|
11
11
|
gemspec.add_dependency('rails', '>= 2.2.0')
|
12
12
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/db-charmer.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{db-charmer}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Alexey Kovyrin"]
|
12
|
-
s.date = %q{2009-09-
|
11
|
+
s.authors = ["Alexey Kovyrin", "Gleb Pomykalov"]
|
12
|
+
s.date = %q{2009-09-25}
|
13
13
|
s.description = %q{ActiveRecord Connections Magic (slaves, multiple connections, etc)}
|
14
|
-
s.email = %q{
|
14
|
+
s.email = %q{gleb.pomykalov@qik.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.rdoc"
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"db-charmer.gemspec",
|
27
27
|
"init.rb",
|
28
28
|
"lib/db_charmer.rb",
|
29
|
+
"lib/db_charmer/action_controller_extensions.rb",
|
29
30
|
"lib/db_charmer/active_record_extensions.rb",
|
30
31
|
"lib/db_charmer/association_proxy.rb",
|
31
32
|
"lib/db_charmer/connection_factory.rb",
|
@@ -36,11 +37,11 @@ Gem::Specification.new do |s|
|
|
36
37
|
"lib/db_charmer/multi_db_migrations.rb",
|
37
38
|
"lib/db_charmer/multi_db_proxy.rb"
|
38
39
|
]
|
39
|
-
s.homepage = %q{http://github.com/
|
40
|
+
s.homepage = %q{http://github.com/glebpom/db-charmer}
|
40
41
|
s.rdoc_options = ["--charset=UTF-8"]
|
41
42
|
s.require_paths = ["lib"]
|
42
43
|
s.rubygems_version = %q{1.3.5}
|
43
|
-
s.summary = %q{ActiveRecord Connections Magic}
|
44
|
+
s.summary = %q{ActiveRecord Connections Magic (qik.com version)}
|
44
45
|
|
45
46
|
if s.respond_to? :specification_version then
|
46
47
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module DbCharmer
|
2
|
+
module ActionControllerExtensions
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def force_master_db(*models)
|
9
|
+
models_array = case models
|
10
|
+
when String, Symbol
|
11
|
+
[models]
|
12
|
+
when Array
|
13
|
+
models
|
14
|
+
when nil
|
15
|
+
#use all models
|
16
|
+
else
|
17
|
+
raise ArgumentError, "You should specify correct list of models"
|
18
|
+
end.map { |m| m.to_s.camelize.constantize }
|
19
|
+
|
20
|
+
old_proxies = {}
|
21
|
+
append_around_filter do |c,a|
|
22
|
+
begin
|
23
|
+
models_array.each do |model|
|
24
|
+
model.db_charmer_connection_level += 1
|
25
|
+
old_proxies[model.object_id] = model.db_charmer_connection_proxy
|
26
|
+
model.switch_connection_to(nil, DbCharmer.migration_connections_should_exist?)
|
27
|
+
end
|
28
|
+
a.call
|
29
|
+
ensure
|
30
|
+
models_array.each do |model|
|
31
|
+
model.switch_connection_to(old_proxies[model.object_id], DbCharmer.migration_connections_should_exist?)
|
32
|
+
model.db_charmer_connection_level -= 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/db_charmer.rb
CHANGED
@@ -56,3 +56,9 @@ ActiveRecord::Migration.extend(DbCharmer::MultiDbMigrations::ClassMethods)
|
|
56
56
|
|
57
57
|
# Enable the magic
|
58
58
|
ActiveRecord::Base.extend(DbCharmer::DbMagic::ClassMethods)
|
59
|
+
|
60
|
+
#Extending ActionController
|
61
|
+
puts "Extending ActionController..."
|
62
|
+
require 'db_charmer/action_controller_extensions'
|
63
|
+
ActionController::Base.send :include, DbCharmer::ActionControllerExtensions
|
64
|
+
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glebpom-db-charmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Kovyrin
|
8
|
+
- Gleb Pomykalov
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-09-
|
13
|
+
date: 2009-09-25 00:00:00 -07:00
|
13
14
|
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -23,7 +24,7 @@ dependencies:
|
|
23
24
|
version: 2.2.0
|
24
25
|
version:
|
25
26
|
description: ActiveRecord Connections Magic (slaves, multiple connections, etc)
|
26
|
-
email:
|
27
|
+
email: gleb.pomykalov@qik.com
|
27
28
|
executables: []
|
28
29
|
|
29
30
|
extensions: []
|
@@ -41,6 +42,7 @@ files:
|
|
41
42
|
- db-charmer.gemspec
|
42
43
|
- init.rb
|
43
44
|
- lib/db_charmer.rb
|
45
|
+
- lib/db_charmer/action_controller_extensions.rb
|
44
46
|
- lib/db_charmer/active_record_extensions.rb
|
45
47
|
- lib/db_charmer/association_proxy.rb
|
46
48
|
- lib/db_charmer/connection_factory.rb
|
@@ -51,7 +53,7 @@ files:
|
|
51
53
|
- lib/db_charmer/multi_db_migrations.rb
|
52
54
|
- lib/db_charmer/multi_db_proxy.rb
|
53
55
|
has_rdoc: false
|
54
|
-
homepage: http://github.com/
|
56
|
+
homepage: http://github.com/glebpom/db-charmer
|
55
57
|
licenses:
|
56
58
|
post_install_message:
|
57
59
|
rdoc_options:
|
@@ -76,6 +78,6 @@ rubyforge_project:
|
|
76
78
|
rubygems_version: 1.3.5
|
77
79
|
signing_key:
|
78
80
|
specification_version: 3
|
79
|
-
summary: ActiveRecord Connections Magic
|
81
|
+
summary: ActiveRecord Connections Magic (qik.com version)
|
80
82
|
test_files: []
|
81
83
|
|