active_record_host_pool 0.7.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3afb58583904ec2e606e050f1a2a13dff283d13e
4
- data.tar.gz: 28250948075a9e1e29778b2fdd4a08075da2d4f7
3
+ metadata.gz: 189352faaaca1fbd14c44dc39277909a0be585c4
4
+ data.tar.gz: b9a1e4b29d44072e893942b7eadebde7d1d870ca
5
5
  SHA512:
6
- metadata.gz: 30de25c6e3cc4f8caf0a1f89ed2d07eda70288e4860728190e8efdd0b82cb1b27010399d35c98465319099526bbe124672d05655f52b474c1bc6e13661eaa557
7
- data.tar.gz: 11d9b5be51cae0d7e23924cf054a6baca3ba4a3ab1080b55b5a73a42213c094106b157d0ae55cb622d627f7627c3df5a3959d770791b429f93918c378cbb6f06
6
+ metadata.gz: 1c9b52b4a9c8f5b72612724533465196755022c1d90bfcdf547f8400e296afce14c20b3462a7ef111cf63477f70ad43188eec099072718b04bdf2ac44fb632ec
7
+ data.tar.gz: 6622d980e61a09900e7ea4810e69fde2e164ca781f347d4727a660095a668fed4ec5e922fa1d5847c12d9999388bf5b347fe9e3eb8fd396ddd6026cf9de83dbf
@@ -32,6 +32,23 @@ module ActiveRecordHostPool
32
32
  @cx.send(:expects, *args)
33
33
  end
34
34
 
35
+ # Override Delegator#respond_to_missing? to allow private methods to be accessed without warning
36
+ def respond_to_missing?(m, include_private)
37
+ __getobj__.respond_to?(m, include_private)
38
+ end
39
+
40
+ def private_methods(all=true)
41
+ __getobj__.private_methods(all) | super
42
+ end
43
+
44
+ def send(symbol, *args, &blk)
45
+ if respond_to?(symbol, true) && !__getobj__.respond_to?(symbol, true)
46
+ super
47
+ else
48
+ __getobj__.send(symbol, *args, &blk)
49
+ end
50
+ end
51
+
35
52
  private
36
53
  def select(*args)
37
54
  @cx.__send__(:select, *args)
data/test/helper.rb CHANGED
@@ -26,7 +26,7 @@ module ARHPTestSetup
26
26
  next if name =~ /not_there/
27
27
  `echo "drop DATABASE IF EXISTS #{conf['database']}" | mysql --user=#{conf['username']}`
28
28
  `echo "create DATABASE #{conf['database']}" | mysql --user=#{conf['username']}`
29
- ActiveRecord::Base.establish_connection(name)
29
+ ActiveRecord::Base.establish_connection(name.to_sym)
30
30
  ActiveRecord::Migration.verbose = false
31
31
  load(File.dirname(__FILE__) + "/schema.rb")
32
32
  end
@@ -43,27 +43,27 @@ module ARHPTestSetup
43
43
  eval <<-EOL
44
44
  class Test1 < ActiveRecord::Base
45
45
  self.table_name = "tests"
46
- establish_connection("test_host_1_db_1")
46
+ establish_connection(:test_host_1_db_1)
47
47
  end
48
48
 
49
49
  class Test2 < ActiveRecord::Base
50
50
  self.table_name = "tests"
51
- establish_connection("test_host_1_db_2")
51
+ establish_connection(:test_host_1_db_2)
52
52
  end
53
53
 
54
54
  class Test3 < ActiveRecord::Base
55
55
  self.table_name = "tests"
56
- establish_connection("test_host_2_db_3")
56
+ establish_connection(:test_host_2_db_3)
57
57
  end
58
58
 
59
59
  class Test4 < ActiveRecord::Base
60
60
  self.table_name = "tests"
61
- establish_connection("test_host_2_db_4")
61
+ establish_connection(:test_host_2_db_4)
62
62
  end
63
63
 
64
64
  class Test5 < ActiveRecord::Base
65
65
  self.table_name = "tests"
66
- establish_connection("test_host_2_db_5")
66
+ establish_connection(:test_host_2_db_5)
67
67
  end
68
68
  EOL
69
69
  end
data/test/test_arhp.rb CHANGED
@@ -32,6 +32,20 @@ class ActiveRecordHostPoolTest < MiniTest::Unit::TestCase
32
32
  assert Test1.connection.is_a?(ActiveRecordHostPool::ConnectionProxy)
33
33
  end
34
34
 
35
+ def test_connection_proxy_handles_private_methods
36
+ # Relies on connection.class returning the real class
37
+ Test1.connection.class.class_eval do
38
+ private
39
+ def test_private_method
40
+ true
41
+ end
42
+ end
43
+ assert Test1.connection.respond_to?(:test_private_method, true)
44
+ refute Test1.connection.respond_to?(:test_private_method)
45
+ assert_includes(Test1.connection.private_methods, :test_private_method)
46
+ assert(Test1.connection.send(:test_private_method) == true)
47
+ end
48
+
35
49
  def test_should_not_share_a_query_cache
36
50
  Test1.create(:val => 'foo')
37
51
  Test2.create(:val => 'foobar')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_host_pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: wwtd
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: ''
28
42
  email:
29
43
  - ben@gimbo.net