slavery 1.2.0 → 1.3.0

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: cf1496eaaf7ad5d9839bf821fc4fafd5b48d2f4c
4
- data.tar.gz: 6b3f1389be627e4e46af04b15b31a6efbba80907
3
+ metadata.gz: 193d19b53ea789af5b97def5fa5ff2a81a857851
4
+ data.tar.gz: 2455c70b2f8cca63d2c19f0894560add559d9531
5
5
  SHA512:
6
- metadata.gz: a5c25149caf8f300de53c07e7c2f3892ee1ff1d06972332357fae177a7a407aac2417467e0a60695f03e69552a38c5cd6aeea8670e2003220768770a01a7dd34
7
- data.tar.gz: aa386b5a735bd33ff57338e20bcfb0928dc1d8e8aa9092e4452f0f87d8f10e05e522b1dc7f62a94f6345545c308ce18563f89364013bd906bd74a5fadb1f08e6
6
+ metadata.gz: aa80b75e90e591c59976fb9a115f6ec9a5462d7e8de2f5029cacc8b349f64dd9168fbb305709fbb521b1dac6c9f2ab7fcac8e61b041b45d4fb71ef6ea55dc215
7
+ data.tar.gz: 810f70d687978c7d82ffd7fade2562d722894869c7310b0ebf2391c9c8d9114e6fa0effb5608dae64200c6407afae81107b41d97439644ed536491f3773c7060
@@ -47,7 +47,9 @@ module Slavery
47
47
 
48
48
  module ClassMethods
49
49
  def on_slave
50
- context = scoped
50
+ # Why where(nil)?
51
+ # http://stackoverflow.com/questions/18198963/with-rails-4-model-scoped-is-deprecated-but-model-all-cant-replace-it
52
+ context = where(nil)
51
53
  context.slavery_target = :slave
52
54
  context
53
55
  end
@@ -83,6 +85,10 @@ module Slavery
83
85
  @slave_connection_holder ||= Class.new(ActiveRecord::Base) {
84
86
  self.abstract_class = true
85
87
 
88
+ def self.name
89
+ "SlaveConnectionHolder"
90
+ end
91
+
86
92
  spec = ["#{Slavery.env}_slave", Slavery.env].find do |spec|
87
93
  ActiveRecord::Base.configurations[spec]
88
94
  end or raise Error.new("#{Slavery.env}_slave or #{Slavery.env} must exist!")
@@ -1,7 +1,7 @@
1
1
  class ActiveRecord::Relation
2
2
  attr_accessor :slavery_target
3
3
 
4
- # Supports queries like User.on_slave.all
4
+ # Supports queries like User.on_slave.to_a
5
5
  def exec_queries_with_slavery
6
6
  if slavery_target == :slave
7
7
  Slavery.on_slave { exec_queries_without_slavery }
@@ -1,3 +1,3 @@
1
1
  module Slavery
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -57,8 +57,10 @@ describe Slavery do
57
57
  User.count.should == 2
58
58
  User.on_slave.count.should == 1
59
59
 
60
- User.scoped.to_a.size.should == 2
61
- User.on_slave.scoped.to_a.size.should == 1
60
+ # Why where(nil)?
61
+ # http://stackoverflow.com/questions/18198963/with-rails-4-model-scoped-is-deprecated-but-model-all-cant-replace-it
62
+ User.where(nil).to_a.size.should == 2
63
+ User.on_slave.where(nil).to_a.size.should == 1
62
64
  end
63
65
 
64
66
  describe 'configuration' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slavery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenn Ejima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-23 00:00:00.000000000 Z
11
+ date: 2013-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord