switchman 2.0.2 → 2.0.3

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
  SHA256:
3
- metadata.gz: 376bc704492af36189c96e77637f3f1e1f8290f25e80a65c5bfe100cd87945d5
4
- data.tar.gz: 9af4f9c45b7e958ffdfca22cb98a4287c2b2fd35f4cbe7dd80a640df7d25c55c
3
+ metadata.gz: 5205c32993056a0fa71d272a95c5306d17762b31971c6242b0fd40e3b587a591
4
+ data.tar.gz: fd445dbeb2e0654e591a461637fa3720a7b335d1307e6ecf289ce88caac17d2d
5
5
  SHA512:
6
- metadata.gz: 4cdf5640f5128c0d0d8235d2446bf676d7ff25bf934e8f266b98f27a45e397e015750bd4928332514a1202f585d84a70ac0c5a3c92db4a3533cf9fdd5a3619c6
7
- data.tar.gz: 40de3daa0b556f247243fd6cff2c7fdad620c7e0b74b58d5735dd984919ffbbe48b96412e50ba62ac169bc6d076f055fef1503e0a09f25848beecdae54c1165d
6
+ metadata.gz: a7db2fab2fb62cae74a845bff7373584c75057e2e9464ffacc130d053e78b6949e6c971aa29372b0f31ef6d25aba389b1c420fc601e18ae7cd8f1ac89b6b85e5
7
+ data.tar.gz: aa2fcb0523b80507b35f5e2b9cdf14f3793b8354ba26bf8dddd000d6da7d6a4abfc50eb7ef45b4013516282111aabe3dd31b264764378fc9abbc1cb1f5bee9e9
@@ -77,7 +77,7 @@ module Switchman
77
77
  module Association
78
78
  if ::Rails.version >= "5.2" and ::Rails.version < "6.0"
79
79
  def run(preloader)
80
- associated_records_by_owner(preloader).each do |owner, records|
80
+ associated_records_by_owner.each do |owner, records|
81
81
  associate_records_to_owner(owner, records)
82
82
  end
83
83
  end
@@ -104,6 +104,7 @@ module Switchman
104
104
  end
105
105
 
106
106
  def associated_records_by_owner(preloader = nil)
107
+ return @associated_records_by_owner if defined?(@associated_records_by_owner)
107
108
  owners_map = owners_by_key
108
109
 
109
110
  if klass.nil? || owners_map.empty?
@@ -151,10 +152,13 @@ module Switchman
151
152
  records.flatten!
152
153
  end
153
154
 
155
+ # This ivar may look unused, but remember this is an extension of
156
+ # rails' AR::Associations::Preloader::Association class. It gets used
157
+ # by that class (and its subclasses).
154
158
  @preloaded_records = records
155
159
 
156
160
  # Each record may have multiple owners, and vice-versa
157
- records_by_owner = owners.each_with_object({}) do |owner,h|
161
+ @associated_records_by_owner = owners.each_with_object({}) do |owner,h|
158
162
  h[owner] = []
159
163
  end
160
164
  records.each do |record|
@@ -163,10 +167,10 @@ module Switchman
163
167
 
164
168
  owners_map[owner_key.to_s].each do |owner|
165
169
  owner.association(reflection.name).set_inverse_instance(record)
166
- records_by_owner[owner] << record
170
+ @associated_records_by_owner[owner] << record
167
171
  end
168
172
  end
169
- records_by_owner
173
+ @associated_records_by_owner
170
174
  end
171
175
 
172
176
  def owners_by_key
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "2.0.2"
4
+ VERSION = "2.0.3"
5
5
  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: 2.0.2
4
+ version: 2.0.3
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: 2020-11-06 00:00:00.000000000 Z
13
+ date: 2021-01-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -140,16 +140,30 @@ dependencies:
140
140
  name: rspec-rails
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 3.5.2
145
+ version: '3.5'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.5'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-mocks
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.5'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 3.5.2
166
+ version: '3.5'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement