active_record_inherit_assoc 2.8.0 → 2.9.0

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
- SHA1:
3
- metadata.gz: 8bd387d89684408a56073510d1a9b3d14b119b2a
4
- data.tar.gz: 39514eaff5903fb90e2a853e8fd1896678d36179
2
+ SHA256:
3
+ metadata.gz: b55c3f0e3b88e52836c8412b5f90299f6bfb5cd3850338328b58e3409afdeefd
4
+ data.tar.gz: 743abb357de27dd7954bbbabc1a72ef95ac9928b4762f8031ba55082bb7fed2d
5
5
  SHA512:
6
- metadata.gz: a5961ad5fefe3009e6ebec716ea1ca81de282db1ee4acf68267d9a838446c13c3860c61712dc94773f5e878917def5f5c2e2140702e1e23d79582a95e776614c
7
- data.tar.gz: 1c4469bd61211da0e0f85a1603024a7c0c644de3ac68cddf38e5c72202cae165c8f4311f4536538da9c376879168547bb726616244bd00e22e0466cac7f88ed4
6
+ metadata.gz: e911e8243061ca030b4293150cd433c1963f72154b849754d2460f02fa85e5b885a691ad3fe7df442de3cb5539fb70b016f100a7bbf0f578a51d9d3d38d42d26
7
+ data.tar.gz: 0ad8b533b645a0f71bc7e9978afb571ccdaad7fe889f6d1015b411f457268b62b86cab07d17acaa02cce904d332603606bb4cdb27bd2c521123773e7c4c9df6a
@@ -3,6 +3,7 @@ require 'active_record'
3
3
  case ActiveRecord::VERSION::MAJOR
4
4
  when 4
5
5
  ActiveRecord::Associations::Builder::Association.valid_options << :inherit
6
+ ActiveRecord::Associations::Builder::Association.valid_options << :inherit_if
6
7
  when 5
7
8
  # We can't add options into `valid_options` anymore.
8
9
  # Here are the possible solutions:
@@ -12,6 +13,7 @@ when 5
12
13
  #
13
14
  # I went with the first one out of simplicity.
14
15
  ActiveRecord::Associations::Builder::Association::VALID_OPTIONS << :inherit
16
+ ActiveRecord::Associations::Builder::Association::VALID_OPTIONS << :inherit_if
15
17
  end
16
18
 
17
19
  module ActiveRecordInheritAssocPrepend
@@ -30,6 +32,7 @@ module ActiveRecordInheritAssocPrepend
30
32
 
31
33
  Array(reflection.options[:inherit]).each_with_object({}) do |association, hash|
32
34
  assoc_value = owner.send(association)
35
+ next if reflection.options[:inherit_if] && !reflection.options[:inherit_if].call(owner)
33
36
  hash[association] = assoc_value
34
37
  hash["#{through_reflection.table_name}.#{association}"] = assoc_value if reflection.options.key?(:through)
35
38
  end
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.8.0
4
+ version: 2.9.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-04-17 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -169,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubyforge_project:
173
- rubygems_version: 2.6.14.4
172
+ rubygems_version: 3.0.3
174
173
  signing_key:
175
174
  specification_version: 4
176
175
  summary: Attribute inheritance for AR associations