db-charmer 1.6.8 → 1.6.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 1.6.9 (2010-04-08):
2
+
3
+ Bugfix release: now DbCharmer works without Rails.
4
+
5
+ ----------------------------------------------------------------------------------------
1
6
  1.6.7 (2010-04-07):
2
7
 
3
8
  Changed the way we handle associations in on_db(:foo).find(:include) calls. Now we
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.8
1
+ 1.6.9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{db-charmer}
8
- s.version = "1.6.8"
8
+ s.version = "1.6.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexey Kovyrin"]
12
- s.date = %q{2010-04-07}
12
+ s.date = %q{2010-04-08}
13
13
  s.description = %q{ActiveRecord Connections Magic (slaves, multiple connections, etc)}
14
14
  s.email = %q{alexey@kovyrin.net}
15
15
  s.extra_rdoc_files = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/db_charmer/connection_factory.rb",
34
34
  "lib/db_charmer/connection_proxy.rb",
35
35
  "lib/db_charmer/connection_switch.rb",
36
+ "lib/db_charmer/core_extensions.rb",
36
37
  "lib/db_charmer/db_magic.rb",
37
38
  "lib/db_charmer/finder_overrides.rb",
38
39
  "lib/db_charmer/multi_db_migrations.rb",
@@ -63,10 +63,12 @@ require 'blankslate'
63
63
 
64
64
  require 'db_charmer/active_record_extensions'
65
65
  require 'db_charmer/abstract_adapter_extensions'
66
+ require 'db_charmer/core_extensions'
66
67
 
67
68
  require 'db_charmer/connection_factory'
68
69
  require 'db_charmer/connection_proxy'
69
70
  require 'db_charmer/connection_switch'
71
+ require 'db_charmer/stub_connection'
70
72
  require 'db_charmer/scope_proxy'
71
73
  require 'db_charmer/multi_db_proxy'
72
74
 
@@ -2,17 +2,20 @@ module DbCharmer
2
2
  module AssociationPreload
3
3
  module ClassMethods
4
4
  ASSOCIATION_TYPES = [ :has_one, :has_many, :belongs_to, :has_and_belongs_to_many ]
5
- ASSOCIATION_TYPES.each do |association_type|
6
- class_eval <<-EOF, __FILE__, __LINE__ + 1
7
- def preload_#{association_type}_association(records, reflection, preload_options = {})
8
- if self.db_charmer_top_level_connection? || self.db_charmer_default_connection != reflection.klass.db_charmer_default_connection
9
- return super(records, reflection, preload_options)
5
+
6
+ def self.extended(base)
7
+ ASSOCIATION_TYPES.each do |association_type|
8
+ base.class_eval <<-EOF, __FILE__, __LINE__ + 1
9
+ def self.preload_#{association_type}_association(records, reflection, preload_options = {})
10
+ if self.db_charmer_top_level_connection? || self.db_charmer_default_connection != reflection.klass.db_charmer_default_connection
11
+ return super(records, reflection, preload_options)
12
+ end
13
+ reflection.klass.on_db(self) do
14
+ super(records, reflection, preload_options)
15
+ end
10
16
  end
11
- reflection.klass.on_db(self) do
12
- super(records, reflection, preload_options)
13
- end
14
- end
15
- EOF
17
+ EOF
18
+ end
16
19
  end
17
20
  end
18
21
  end
@@ -0,0 +1,13 @@
1
+ class Object
2
+ unless defined?(try)
3
+ def try(method, *options, &block)
4
+ send(method, *options, &block)
5
+ end
6
+ end
7
+ end
8
+
9
+ class NilClass
10
+ def try(method, *options, &block)
11
+ nil
12
+ end
13
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 6
8
- - 8
9
- version: 1.6.8
8
+ - 9
9
+ version: 1.6.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alexey Kovyrin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-07 00:00:00 -04:00
17
+ date: 2010-04-08 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -69,6 +69,7 @@ files:
69
69
  - lib/db_charmer/connection_factory.rb
70
70
  - lib/db_charmer/connection_proxy.rb
71
71
  - lib/db_charmer/connection_switch.rb
72
+ - lib/db_charmer/core_extensions.rb
72
73
  - lib/db_charmer/db_magic.rb
73
74
  - lib/db_charmer/finder_overrides.rb
74
75
  - lib/db_charmer/multi_db_migrations.rb