active_record_inherit_assoc 2.5.0 → 2.5.1

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
  SHA1:
3
- metadata.gz: ea75f7b36b592c164adc0681e3ce45891db2db2c
4
- data.tar.gz: 39fc2cbc13071657fbe1b1352ced4d598da58572
3
+ metadata.gz: 5744502d4b1e1941a08f829565227940755e2242
4
+ data.tar.gz: 5f27dc1364e9859a0cae9dd40d03cafa25f57534
5
5
  SHA512:
6
- metadata.gz: 03ff93fd9cc642d5a15eaec01718cb9671267826a95822ee6ca8aaf58eb46d2afd2ef7b384c16e1b0a5395bfc16926ad145d1202a9b68cca25fc73fdefd85cc4
7
- data.tar.gz: 30d3fd6d78a8c18acd10f9e2c56452847d694def8650a789f18fe4fe8c41a4c27d7c36993d7dd4e9f739044c40f1ac28fb5dc9b6b92afe34acd8f7ad3ff366e2
6
+ metadata.gz: ac5a23f39ff9ed338c004966f7e0077c27c71309932636379af39a49598abab216718481f0f91d2b21550cc9acc5b202a48599dadea739aa3e31865111e70924
7
+ data.tar.gz: e9eaa77c7e46fec4faf8401828144b1d84b12d6250cef9205d1ad817fdd330d3e7c60a59c7896b0ad278cb46c6693d13bc29c2269ddfd3e7feebbd65421478da
@@ -35,7 +35,7 @@ module ActiveRecordInheritAssocPrepend
35
35
  end
36
36
 
37
37
  if ActiveRecord::VERSION::MAJOR >= 4
38
- def skip_statement_cache?
38
+ def skip_statement_cache?(*)
39
39
  super || !!reflection.options[:inherit]
40
40
  end
41
41
  end
@@ -44,13 +44,23 @@ end
44
44
  ActiveRecord::Associations::Association.send(:prepend, ActiveRecordInheritAssocPrepend)
45
45
 
46
46
  module ActiveRecordInheritPreloadAssocPrepend
47
- def associated_records_by_owner(*args)
48
- super.tap do |result|
49
- next unless inherit = reflection.options[:inherit]
50
- result.each do |owner, associated_records|
51
- filter_associated_records_with_inherit!(owner, associated_records, inherit)
47
+ if ActiveRecord::VERSION::STRING < '5.2.0'
48
+ def associated_records_by_owner(*)
49
+ super.tap do |result|
50
+ next unless inherit = reflection.options[:inherit]
51
+ result.each do |owner, associated_records|
52
+ filter_associated_records_with_inherit!(owner, associated_records, inherit)
53
+ end
52
54
  end
53
55
  end
56
+ else
57
+ def associate_records_to_owner(owner, records)
58
+ if inherit = reflection.options[:inherit]
59
+ records = Array(records)
60
+ filter_associated_records_with_inherit!(owner, records, inherit)
61
+ end
62
+ super
63
+ end
54
64
  end
55
65
 
56
66
  def filter_associated_records_with_inherit!(owner, associated_records, inherit)
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.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-12-29 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.6.11
173
+ rubygems_version: 2.6.14
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Attribute inheritance for AR associations