active_record_inherit_assoc 2.7.0 → 2.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 492331a685418fa3a1fb9de5f9b9e368271cda4ef228223a229416a742d6dfb5
4
- data.tar.gz: cda8957c1fe83ac64a9e7dd257a45c397e9bb8c6ba351c1bd25cbebfe9333e05
2
+ SHA1:
3
+ metadata.gz: 8bd387d89684408a56073510d1a9b3d14b119b2a
4
+ data.tar.gz: 39514eaff5903fb90e2a853e8fd1896678d36179
5
5
  SHA512:
6
- metadata.gz: 1fc9fa5f73d3d24860badc833ecead64d4b69db0266fa260e7a143dde47de5b67542e027ce8c183cca57b31ee347938cea6f995b54565ea4610ae1a8c42e4a0d
7
- data.tar.gz: 18407bef501e125baa7c670a38ac9aff3b17721d036b5fb5b6ce6099f836a8bc6f96bf6ee0e323e4556e5879af3f389b4de8d2c95c078f7d296dbeaca6c40d0a
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
- Array(reflection.options[:inherit]).inject({}) do |hash, association|
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.7.0
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-02-04 00:00:00.000000000 Z
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.7.6
173
+ rubygems_version: 2.6.14.4
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Attribute inheritance for AR associations