switchman 1.7.3 → 1.7.4
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 +4 -4
- data/lib/switchman/active_record/reflection.rb +27 -13
- data/lib/switchman/engine.rb +2 -0
- data/lib/switchman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2287cafb5c656fc9033e4549edec54e5497977b5
|
4
|
+
data.tar.gz: 0a5c7fb962a37016087842675dfc37f90ccd697b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c6200530e3662721b2eb0f66dee5107f9d8200fbd90229974d3be29d875d8328c71b9971b5d1e6a39d69e02e74fe2c7491c81630a4fa0c9e01ea58dff6b3067
|
7
|
+
data.tar.gz: 9044787290f4ce2bca81c26cba8c83c6ee4284fbea4afcf17223a8586d333e4bd119fd2472cbaadaee77701b58dc5ab839d367f070e257db1d2be6285f682914
|
@@ -12,21 +12,21 @@ module Switchman
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
if ::Rails.version >= '4.2'
|
16
|
+
module AssociationScopeCache
|
17
|
+
def initialize(*args)
|
18
|
+
super
|
19
|
+
# on ThroughReflection, these won't be initialized (cause it doesn't
|
20
|
+
# inherit from AssociationReflection), so make sure they're
|
21
|
+
# initialized here
|
22
|
+
@association_scope_cache ||= {}
|
23
|
+
@scope_lock ||= Mutex.new
|
21
24
|
end
|
22
|
-
else
|
23
|
-
def join_id_for(owner)
|
24
|
-
owner.send(active_record_primary_key) # use sharded id values in association binds
|
25
|
-
end
|
26
|
-
end
|
27
25
|
|
28
|
-
|
29
|
-
|
26
|
+
# cache association scopes by shard.
|
27
|
+
# this technically belongs on AssociationReflection, but we put it on
|
28
|
+
# ThroughReflection as well, instead of delegating to its internal
|
29
|
+
# HasManyAssociation, losing its proper `klass`
|
30
30
|
def association_scope_cache(conn, owner)
|
31
31
|
key = conn.prepared_statements
|
32
32
|
if polymorphic?
|
@@ -39,6 +39,20 @@ module Switchman
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
module AssociationReflection
|
44
|
+
# removes memoization - ActiveRecord::ModelSchema does that anyway;
|
45
|
+
# and in fact this is the exact change AR makes in 4.2+
|
46
|
+
if ::Rails.version < '4.2'
|
47
|
+
def quoted_table_name
|
48
|
+
klass.quoted_table_name
|
49
|
+
end
|
50
|
+
else
|
51
|
+
def join_id_for(owner)
|
52
|
+
owner.send(active_record_primary_key) # use sharded id values in association binds
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
42
56
|
end
|
43
57
|
end
|
44
58
|
end
|
data/lib/switchman/engine.rb
CHANGED
@@ -134,6 +134,8 @@ module Switchman
|
|
134
134
|
::ActiveRecord::LogSubscriber.prepend(ActiveRecord::LogSubscriber)
|
135
135
|
if ::Rails.version >= '4.2'
|
136
136
|
::ActiveRecord::Reflection::AbstractReflection.include(ActiveRecord::Reflection::AbstractReflection)
|
137
|
+
::ActiveRecord::Reflection::AssociationReflection.prepend(ActiveRecord::Reflection::AssociationScopeCache)
|
138
|
+
::ActiveRecord::Reflection::ThroughReflection.prepend(ActiveRecord::Reflection::AssociationScopeCache)
|
137
139
|
else
|
138
140
|
::ActiveRecord::Reflection::AssociationReflection.include(ActiveRecord::Reflection::AbstractReflection)
|
139
141
|
end
|
data/lib/switchman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-10-
|
13
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|