switchman 1.7.3 → 1.7.4

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: 8ac20dcf634164e03ce0325d01a492a6b9f37ea6
4
- data.tar.gz: c6e4c46ce8b9dbc04a39678cbd892e7f4ab1e852
3
+ metadata.gz: 2287cafb5c656fc9033e4549edec54e5497977b5
4
+ data.tar.gz: 0a5c7fb962a37016087842675dfc37f90ccd697b
5
5
  SHA512:
6
- metadata.gz: aed3e8db98ce052fbd21cead9d100cadc1822d20c5fa37eaee88d91bb25e9caedee72f0ce3f160b3d106359814796b43459a851e71e420cafe2ea1f8181a997a
7
- data.tar.gz: 0f25cdd4c7c85f4ffd6d7c32ebfc0262d2c9593788ebebaaf71d970cfaa947ea47ba2bf40fc9d4834f06b941586ba355123cfd99952367a23b95ba68cb0829ae
6
+ metadata.gz: 9c6200530e3662721b2eb0f66dee5107f9d8200fbd90229974d3be29d875d8328c71b9971b5d1e6a39d69e02e74fe2c7491c81630a4fa0c9e01ea58dff6b3067
7
+ data.tar.gz: 9044787290f4ce2bca81c26cba8c83c6ee4284fbea4afcf17223a8586d333e4bd119fd2472cbaadaee77701b58dc5ab839d367f070e257db1d2be6285f682914
@@ -12,21 +12,21 @@ module Switchman
12
12
  end
13
13
  end
14
14
 
15
- module AssociationReflection
16
- # removes memoization - ActiveRecord::ModelSchema does that anyway;
17
- # and in fact this is the exact change AR makes in 4.2+
18
- if ::Rails.version < '4.2'
19
- def quoted_table_name
20
- klass.quoted_table_name
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
- # cache association scopes by shard.
29
- if ::Rails.version >= '4.2'
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Switchman
2
- VERSION = "1.7.3"
2
+ VERSION = "1.7.4"
3
3
  end
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.3
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-27 00:00:00.000000000 Z
13
+ date: 2016-10-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties