iknow_view_models 3.7.5 → 3.7.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 849a8c0a38a21b8d8d8c706aae9800c2d5b009a81e59432d501cc0cef8329db3
|
4
|
+
data.tar.gz: b9cfa60ace9c9f6af4c711f7ae11fd8aa76934bcef7d6e7b360b749fe667d4b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e510f3a65791a27df5be2eabb889bd5a5addb84ee17f4e1b2f1ff7b76dfb1630978e3fc1b90bc1c26b36a83d9bb6892e9c3eb7e235b7f762946ab0c3b9b4ab4
|
7
|
+
data.tar.gz: 67f12f88ce24394ddcaa639008a66ea0120fa5e062463fed5c4d30e0f20a75e7dda7823f025304b3cf4d1cda9e5640cbe281f459aab22f84ed5a4d920eb7f9b6
|
@@ -97,6 +97,15 @@ module ViewModel::ActiveRecord::Controller
|
|
97
97
|
|
98
98
|
def migration_versions
|
99
99
|
@migration_versions ||=
|
100
|
+
begin
|
101
|
+
specified_migration_versions.reject do |viewmodel_class, required_version|
|
102
|
+
viewmodel_class.schema_version == required_version
|
103
|
+
end.freeze
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def specified_migration_versions
|
108
|
+
@specified_migration_versions ||=
|
100
109
|
begin
|
101
110
|
version_spec =
|
102
111
|
if params.include?(:versions)
|
@@ -121,10 +130,7 @@ module ViewModel::ActiveRecord::Controller
|
|
121
130
|
|
122
131
|
versions.each do |view_name, required_version|
|
123
132
|
viewmodel_class = ViewModel::Registry.for_view_name(view_name)
|
124
|
-
|
125
|
-
if viewmodel_class.schema_version != required_version
|
126
|
-
migration_versions[viewmodel_class] = required_version
|
127
|
-
end
|
133
|
+
migration_versions[viewmodel_class] = required_version
|
128
134
|
rescue ViewModel::DeserializationError::UnknownView
|
129
135
|
# Ignore requests to migrate types that no longer exist
|
130
136
|
next
|
@@ -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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|