active_record_shards 3.4.3 → 3.5.0.pre.alpha

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: 560297ec2853470b0022c84d8dd57c15a40589cf
4
- data.tar.gz: fd7b67c7d15b63d24d1c7f8d2cbebcaeaf5c7816
3
+ metadata.gz: 2f5934528264e0c87553401c8e2c2f46c54e7da9
4
+ data.tar.gz: 5ab7c3b24998adf54238edaea4cb8bb088c103b3
5
5
  SHA512:
6
- metadata.gz: 498854a4c1bcf28b74b9af9317c69d925bcc4aa1a3d00bec5ade25978e7203ed952c0a46ee402918160bb317a2c22ae5e40e1c1c3b47b6ac58823d8bc7892324
7
- data.tar.gz: 43e2d7bd3a71a22941405370b6544b112e0cc0ea750912599a74c37338e802425dd81a654133330211171db88de3b79e0be71bf64ca8112c800dafdb1c69d7bb
6
+ metadata.gz: 8198cd8aedfc3dbebdc413fbc8c5c6eb9ade10539853700c8cd1666e574c8dcdcc777d306d9d9615aef74e331082bbdbed15a713931a80a57f324190e43a4bfa
7
+ data.tar.gz: 13d1be9a552f677a2ac9be01b82b372b1817868f1edeb07ffe3111b9388ab19d35563a25597fd46844385a112230d2ad2c4bedf44a661396ffae5f3d464f84ca
@@ -2,6 +2,8 @@ require 'active_record_shards/shard_support'
2
2
 
3
3
  module ActiveRecordShards
4
4
  module ConnectionSwitcher
5
+ SHARD_NAMES_CONFIG_KEY = 'shard_names'.freeze
6
+
5
7
  def self.extended(klass)
6
8
  klass.singleton_class.alias_method_chain :columns, :default_shard
7
9
  klass.singleton_class.alias_method_chain :table_exists?, :default_shard
@@ -144,7 +146,7 @@ module ActiveRecordShards
144
146
  unless config = configurations[shard_env]
145
147
  raise "Did not find #{shard_env} in configurations, did you forget to add it to your database.yml ? (configurations: #{configurations.inspect})"
146
148
  end
147
- config['shard_names'] || []
149
+ config[SHARD_NAMES_CONFIG_KEY] || []
148
150
  end
149
151
 
150
152
  private
@@ -12,7 +12,7 @@ module ActiveRecordShards
12
12
  if @shard == NO_SHARD
13
13
  nil
14
14
  else
15
- (@shard || self.class.default_shard).to_s
15
+ @shard || self.class.default_shard
16
16
  end
17
17
  end
18
18
  end
@@ -32,12 +32,10 @@ module ActiveRecordShards
32
32
  def shard_name(klass = nil, try_slave = true)
33
33
  the_shard = shard(klass)
34
34
 
35
- # Tradeoff: An Array is a slower Hash key, but joining its elements into
36
- # one string would generate 3 new String objects needing GC later.
37
- key = [ActiveRecordShards.rails_env, the_shard, try_slave, @on_slave]
38
-
39
- @shard_names ||= {}
40
- @shard_names[key] ||= begin
35
+ @shard_names ||= {}
36
+ @shard_names[the_shard] ||= {}
37
+ @shard_names[the_shard][try_slave] ||= {}
38
+ @shard_names[the_shard][try_slave][@on_slave] ||= begin
41
39
  s = ActiveRecordShards.rails_env.dup
42
40
  s << "_shard_#{the_shard}" if the_shard
43
41
  s << "_slave" if @on_slave && try_slave
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.3
4
+ version: 3.5.0.pre.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-29 00:00:00.000000000 Z
13
+ date: 2015-08-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -189,12 +189,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - ">"
193
193
  - !ruby/object:Gem::Version
194
- version: '0'
194
+ version: 1.3.1
195
195
  requirements: []
196
196
  rubyforge_project:
197
- rubygems_version: 2.2.2
197
+ rubygems_version: 2.4.5
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: Simple database switching for ActiveRecord.