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 +4 -4
- data/lib/active_record_inherit_assoc.rb +16 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5744502d4b1e1941a08f829565227940755e2242
|
4
|
+
data.tar.gz: 5f27dc1364e9859a0cae9dd40d03cafa25f57534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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.
|
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-
|
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.
|
173
|
+
rubygems_version: 2.6.14
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Attribute inheritance for AR associations
|