iknow_view_models 3.7.5 → 3.7.6
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/iknow_view_models/version.rb +1 -1
- data/lib/view_model/active_record/update_operation.rb +20 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4e2ce83aca25f76c562927351a4c3061566428bd6d599f8d1efd3a0fe67b953
|
4
|
+
data.tar.gz: e6f11b57045e611fd9e3133f28fbfe7e9ee42c82edafdaa4a7be9a0c25311080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628bebb67d57d5036640357c5cc9429ada7d84b5fd70d57d9aa1a35244bf1bd50f0d6851d56c7949ef46d54db6c066810f3e7206833419cee16b7b1e9ee1c030
|
7
|
+
data.tar.gz: 497c85d6648b089bb6cac073684cf070becf37b2505b977d13ce2115eaaa7eef68da985713304548241a69b88dba3d2729925ec87ef384792cf721fdcf73b4a7
|
@@ -81,15 +81,15 @@ class ViewModel::ActiveRecord
|
|
81
81
|
viewmodel._list_attribute = reposition_to
|
82
82
|
end
|
83
83
|
|
84
|
+
# Visit attributes and associations as much as possible in the order
|
85
|
+
# that they're declared in the view.
|
86
|
+
member_ordering = viewmodel.class._members.keys.each_with_index.to_h
|
87
|
+
|
84
88
|
# update user-specified attributes
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
causes = bad_keys.map { |k| ViewModel::DeserializationError::UnknownAttribute.new(k, blame_reference) }
|
89
|
-
raise ViewModel::DeserializationError::Collection.for_errors(causes)
|
90
|
-
end
|
89
|
+
attribute_keys = attributes.keys.sort_by { |k| member_ordering[k] }
|
90
|
+
attribute_keys.each do |attr_name|
|
91
|
+
serialized_value = attributes[attr_name]
|
91
92
|
|
92
|
-
attributes.each do |attr_name, serialized_value|
|
93
93
|
# Note that the VM::AR deserialization tree asserts ownership over any
|
94
94
|
# references it's provided, and so they're intentionally not passed on
|
95
95
|
# to attribute deserialization for use by their `using:` viewmodels. A
|
@@ -101,7 +101,13 @@ class ViewModel::ActiveRecord
|
|
101
101
|
end
|
102
102
|
|
103
103
|
# Update points-to associations before save
|
104
|
-
points_to.
|
104
|
+
points_to_keys = points_to.keys.sort_by do |association_data|
|
105
|
+
member_ordering[association_data.association_name]
|
106
|
+
end
|
107
|
+
|
108
|
+
points_to_keys.each do |association_data|
|
109
|
+
child_operation = points_to[association_data]
|
110
|
+
|
105
111
|
reflection = association_data.direct_reflection
|
106
112
|
debug "-> #{debug_name}: Updating points-to association '#{reflection.name}'"
|
107
113
|
|
@@ -138,7 +144,12 @@ class ViewModel::ActiveRecord
|
|
138
144
|
|
139
145
|
# Update association cache of pointed-from associations after save: the
|
140
146
|
# child update will have saved the pointer.
|
141
|
-
pointed_to.
|
147
|
+
pointed_to_keys = pointed_to.keys.sort_by do |association_data|
|
148
|
+
member_ordering[association_data.association_name]
|
149
|
+
end
|
150
|
+
|
151
|
+
pointed_to_keys.each do |association_data|
|
152
|
+
child_operation = pointed_to[association_data]
|
142
153
|
reflection = association_data.direct_reflection
|
143
154
|
|
144
155
|
debug "-> #{debug_name}: Updating pointed-to association '#{reflection.name}'"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iknow_view_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|