active_record_inherit_assoc 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/active_record_inherit_assoc.rb +15 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8bd387d89684408a56073510d1a9b3d14b119b2a
|
4
|
+
data.tar.gz: 39514eaff5903fb90e2a853e8fd1896678d36179
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5961ad5fefe3009e6ebec716ea1ca81de282db1ee4acf68267d9a838446c13c3860c61712dc94773f5e878917def5f5c2e2140702e1e23d79582a95e776614c
|
7
|
+
data.tar.gz: 1c4469bd61211da0e0f85a1603024a7c0c644de3ac68cddf38e5c72202cae165c8f4311f4536538da9c376879168547bb726616244bd00e22e0466cac7f88ed4
|
@@ -27,11 +27,11 @@ module ActiveRecordInheritAssocPrepend
|
|
27
27
|
|
28
28
|
def attribute_inheritance_hash
|
29
29
|
return nil unless reflection.options[:inherit]
|
30
|
-
|
30
|
+
|
31
|
+
Array(reflection.options[:inherit]).each_with_object({}) do |association, hash|
|
31
32
|
assoc_value = owner.send(association)
|
32
33
|
hash[association] = assoc_value
|
33
34
|
hash["#{through_reflection.table_name}.#{association}"] = assoc_value if reflection.options.key?(:through)
|
34
|
-
hash
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -64,6 +64,19 @@ module ActiveRecordInheritPreloadAssocPrepend
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def scope
|
68
|
+
prescope = super
|
69
|
+
|
70
|
+
if inherit = reflection.options[:inherit]
|
71
|
+
Array(inherit).each do |inherit_assoc|
|
72
|
+
owner_values = owners.map(&inherit_assoc).compact.uniq
|
73
|
+
prescope = prescope.where(inherit_assoc => owner_values)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
prescope
|
78
|
+
end
|
79
|
+
|
67
80
|
def filter_associated_records_with_inherit!(owner, associated_records, inherit)
|
68
81
|
associated_records.select! do |record|
|
69
82
|
Array(inherit).all? do |association|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_inherit_assoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Osheroff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.6.14.4
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Attribute inheritance for AR associations
|