deep_unrest 0.1.14 → 0.1.15
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 +4 -4
- data/lib/deep_unrest.rb +17 -0
- data/lib/deep_unrest/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6399b9cf607bb71db3f29983c64bc875e51ad88a
|
4
|
+
data.tar.gz: 43ba25e40fa2e101623686090c4a7969bab2e372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6ed340e24a1949b13c2690ca40bffc0f6cdc1e96c6005e97c033c7b68bdeeaa086db38d5a6ea24a701a6f2e8c8098e45ed050a8002bae97925f03c41316cac9
|
7
|
+
data.tar.gz: dc3bd0f748165261d9431004e7a622069756b1de57ba35a18c111f57417dc451c66c3d416c1906742212e0ebcbe1dba5446ccfe1daa6073a140321460bf0466c
|
data/lib/deep_unrest.rb
CHANGED
@@ -2,6 +2,23 @@
|
|
2
2
|
|
3
3
|
require 'deep_unrest/engine'
|
4
4
|
|
5
|
+
# workaronud for rails bug with association indices.
|
6
|
+
# see https://github.com/rails/rails/pull/24728
|
7
|
+
module ActiveRecord
|
8
|
+
module AutosaveAssociation
|
9
|
+
# Returns the record for an association collection that should be validated
|
10
|
+
# or saved. If +autosave+ is +false+ only new records will be returned,
|
11
|
+
# unless the parent is/was a new record itself.
|
12
|
+
def associated_records_to_validate_or_save(association, new_record, autosave)
|
13
|
+
if new_record || autosave
|
14
|
+
association && association.target
|
15
|
+
else
|
16
|
+
association.target.find_all(&:new_record?)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
5
22
|
# Update deeply nested associations wholesale
|
6
23
|
module DeepUnrest
|
7
24
|
class InvalidParentScope < ::StandardError
|
data/lib/deep_unrest/version.rb
CHANGED