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 +4 -4
- data/lib/switchman/active_record/association.rb +8 -4
- data/lib/switchman/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5205c32993056a0fa71d272a95c5306d17762b31971c6242b0fd40e3b587a591
|
4
|
+
data.tar.gz: fd445dbeb2e0654e591a461637fa3720a7b335d1307e6ecf289ce88caac17d2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
-
|
170
|
+
@associated_records_by_owner[owner] << record
|
167
171
|
end
|
168
172
|
end
|
169
|
-
|
173
|
+
@associated_records_by_owner
|
170
174
|
end
|
171
175
|
|
172
176
|
def owners_by_key
|
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: 2.0.
|
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:
|
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
|
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
|
166
|
+
version: '3.5'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: simplecov
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|