iknow_view_models 3.7.4 → 3.7.6

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
  SHA256:
3
- metadata.gz: c4284905ecbec0ee35c1d61c687ed9bc12dd9030ea600f34584e97333a559141
4
- data.tar.gz: 5270dfdfed945d140452555a32dbdd08ffdbc61dc26d0a6133eced8a3e261244
3
+ metadata.gz: f4e2ce83aca25f76c562927351a4c3061566428bd6d599f8d1efd3a0fe67b953
4
+ data.tar.gz: e6f11b57045e611fd9e3133f28fbfe7e9ee42c82edafdaa4a7be9a0c25311080
5
5
  SHA512:
6
- metadata.gz: 63e53371c1511303ce3d425ccbb586148f116d110b524f3c9ab442936ce9b8456b07aeb269f1da3a5dc410549cb4f1f7a4d64c28e797bf6de8931eb9d2cdaee3
7
- data.tar.gz: 21cc10407f402a6c371c516e08f35664655693518d4d0b78b9d84293a90f019b2b343c6c650b1331643135f8d4f634833deee6aec87cc31c45a461a0ae9fb979
6
+ metadata.gz: 628bebb67d57d5036640357c5cc9429ada7d84b5fd70d57d9aa1a35244bf1bd50f0d6851d56c7949ef46d54db6c066810f3e7206833419cee16b7b1e9ee1c030
7
+ data.tar.gz: 497c85d6648b089bb6cac073684cf070becf37b2505b977d13ce2115eaaa7eef68da985713304548241a69b88dba3d2729925ec87ef384792cf721fdcf73b4a7
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IknowViewModels
4
- VERSION = '3.7.4'
4
+ VERSION = '3.7.6'
5
5
  end
@@ -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
- valid_members = viewmodel.class._members.keys.map(&:to_s).to_set
86
- bad_keys = attributes.keys.reject { |k| valid_members.include?(k) }
87
- if bad_keys.present?
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.each do |association_data, child_operation|
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.each do |association_data, child_operation|
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}'"
@@ -24,7 +24,7 @@ class ViewModel::ErrorView < ViewModel::Record
24
24
  json.context do
25
25
  next json.null! unless exception.respond_to?(:to_honeybadger_context)
26
26
 
27
- json.merge! cause.to_honeybadger_context
27
+ json.merge! exception.to_honeybadger_context
28
28
  end
29
29
  end
30
30
  end
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
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-08-23 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack