iknow_view_models 3.4.3 → 3.4.4
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: 2845e303fc1acc67f0241e30586c39276f08720a824104f71416a5b9d63a8989
|
4
|
+
data.tar.gz: ae89dde77c602debb67793bc36a120739c6692802e227d1835f972b0d72f542f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 808e3772112084fb81efeb7b0229ec461d4318b2f74460e01e94cd4c57c197b6c10b1fe6b0c02f0efa995d9b27209d08de8a98ed2991b270387cdc2b7a6520b4
|
7
|
+
data.tar.gz: 6ffed3458c0a92ddc8a49580073bbc6827eed7be49b1c605ed7708fc995185c825df57d583fd27305d45b4425b806faf0655a81a3eb7be5f9f64cdec9d09dedc
|
data/iknow_view_models.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = 'iknow_view_models'
|
9
9
|
spec.version = IknowViewModels::VERSION
|
10
10
|
spec.authors = ['iKnow Team']
|
11
|
-
spec.email = ['
|
11
|
+
spec.email = ['systems@iknow.jp']
|
12
12
|
spec.summary = 'ViewModels provide a means of encapsulating a collection of related data and specifying its JSON serialization.'
|
13
13
|
spec.description = ''
|
14
14
|
spec.homepage = 'https://github.com/iknow/cerego_view_models'
|
@@ -395,10 +395,10 @@ module ViewModel::ActiveRecord::AssociationManipulation
|
|
395
395
|
def check_association_type!(association_data, type)
|
396
396
|
if type && !association_data.accepts?(type)
|
397
397
|
raise ViewModel::SerializationError.new(
|
398
|
-
"Type error: association '#{
|
398
|
+
"Type error: association '#{association_data.association_name}' can't refer to viewmodel #{type.view_name}")
|
399
399
|
elsif association_data.polymorphic? && !type
|
400
400
|
raise ViewModel::SerializationError.new(
|
401
|
-
"Need to specify target viewmodel type for polymorphic association '#{
|
401
|
+
"Need to specify target viewmodel type for polymorphic association '#{association_data.association_name}'")
|
402
402
|
end
|
403
403
|
end
|
404
404
|
end
|
@@ -52,22 +52,23 @@ class ViewModel::ActiveRecord::Cloner
|
|
52
52
|
new_associated = associated
|
53
53
|
else
|
54
54
|
# Otherwise descend into the child, and attach the result
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
build_vm = ->(model) do
|
56
|
+
vm_class =
|
57
|
+
if association_data.through?
|
58
|
+
# descend into the synthetic join table viewmodel
|
59
|
+
association_data.direct_viewmodel
|
60
|
+
else
|
61
|
+
association_data.viewmodel_class_for_model!(model.class)
|
62
|
+
end
|
63
|
+
|
64
|
+
vm_class.new(model)
|
65
|
+
end
|
65
66
|
|
66
67
|
new_associated =
|
67
68
|
if ViewModel::Utils.array_like?(associated)
|
68
|
-
associated.map { |m| clone(
|
69
|
+
associated.map { |m| clone(build_vm.(m)) }.compact
|
69
70
|
else
|
70
|
-
clone(
|
71
|
+
clone(build_vm.(associated))
|
71
72
|
end
|
72
73
|
end
|
73
74
|
end
|
@@ -75,8 +75,13 @@ module ViewModel::Controller
|
|
75
75
|
protected
|
76
76
|
|
77
77
|
def parse_viewmodel_updates
|
78
|
-
|
79
|
-
|
78
|
+
data_param = params.fetch(:data) do
|
79
|
+
raise ViewModel::Error.new(status: 400, detail: "Missing 'data' parameter")
|
80
|
+
end
|
81
|
+
refs_param = params.fetch(:references, {})
|
82
|
+
|
83
|
+
update_hash = _extract_update_data(data_param)
|
84
|
+
refs = _extract_param_hash(refs_param)
|
80
85
|
|
81
86
|
return update_hash, refs
|
82
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iknow_view_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
@@ -362,7 +362,7 @@ dependencies:
|
|
362
362
|
version: '0'
|
363
363
|
description: ''
|
364
364
|
email:
|
365
|
-
-
|
365
|
+
- systems@iknow.jp
|
366
366
|
executables: []
|
367
367
|
extensions: []
|
368
368
|
extra_rdoc_files: []
|