active_record_shards 3.11.0 → 3.11.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cbfb7e59c8d4f61eed565d7a674fb674ddf2071
|
4
|
+
data.tar.gz: a0cb38cbe1854083eda4a7ccf343cc06e62bb86c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd58f711a2a3754bd44cf99df5dcd1aa465cd97b103da5ba96b527683bd725aacd594da410083d9ef5bd10845ac6281a7704373acd6d222fa29a814cd36df94
|
7
|
+
data.tar.gz: f7a37e019a03eb4645252b2cbcd38d3b71c318b3af27f7aecb467a1b41cf926e21b105e070f361e0a17ea2d7568d7dde3f95b69b645682de7d90e8fbc5d685d9
|
@@ -6,8 +6,13 @@ module ActiveRecordShards
|
|
6
6
|
SHARD_NAMES_CONFIG_KEY = 'shard_names'.freeze
|
7
7
|
|
8
8
|
def self.extended(base)
|
9
|
-
|
10
|
-
|
9
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
10
|
+
base.singleton_class.send(:alias_method, :load_schema_without_default_shard!, :load_schema!)
|
11
|
+
base.singleton_class.send(:alias_method, :load_schema!, :load_schema_with_default_shard!)
|
12
|
+
else
|
13
|
+
base.singleton_class.send(:alias_method, :columns_without_default_shard, :columns)
|
14
|
+
base.singleton_class.send(:alias_method, :columns, :columns_with_default_shard)
|
15
|
+
end
|
11
16
|
|
12
17
|
base.singleton_class.send(:alias_method, :table_exists_without_default_shard?, :table_exists?)
|
13
18
|
base.singleton_class.send(:alias_method, :table_exists?, :table_exists_with_default_shard?)
|
@@ -177,8 +182,14 @@ module ActiveRecordShards
|
|
177
182
|
end
|
178
183
|
end
|
179
184
|
|
180
|
-
|
181
|
-
|
185
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
186
|
+
def load_schema_with_default_shard!
|
187
|
+
with_default_shard { load_schema_without_default_shard! }
|
188
|
+
end
|
189
|
+
else
|
190
|
+
def columns_with_default_shard
|
191
|
+
with_default_shard { columns_without_default_shard }
|
192
|
+
end
|
182
193
|
end
|
183
194
|
|
184
195
|
def table_exists_with_default_shard?
|
@@ -24,11 +24,22 @@ module ActiveRecordShards
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def on_slave_by_default?
|
27
|
-
|
27
|
+
if self == ActiveRecord::Base
|
28
|
+
false
|
29
|
+
else
|
30
|
+
base = base_class
|
31
|
+
if base.instance_variable_defined?(:@on_slave_by_default)
|
32
|
+
base.instance_variable_get(:@on_slave_by_default)
|
33
|
+
end
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
def on_slave_by_default=(value)
|
31
|
-
|
38
|
+
if self == ActiveRecord::Base
|
39
|
+
raise ArgumentError, "Cannot set on_slave_by_default on ActiveRecord::Base"
|
40
|
+
else
|
41
|
+
base_class.instance_variable_set(:@on_slave_by_default, value)
|
42
|
+
end
|
32
43
|
end
|
33
44
|
|
34
45
|
module InstanceMethods
|
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.11.
|
4
|
+
version: 3.11.1
|
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: 2017-09-
|
13
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
231
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
232
|
+
rubygems_version: 2.6.13
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: Simple database switching for ActiveRecord.
|