iknow_view_models 3.0.1 → 3.0.2

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: f9bbcabccc02d9109e4709f5cfd153eb3846816cefb115aef1d81495d799e55d
4
- data.tar.gz: f2de8f5c69cffbfe4a7a5009fa68f0bdb44890ea5febb00510b2e8de5e24ca33
3
+ metadata.gz: 4f643ac9a59994324e3222f51732f5b7a3c34acefebb1e92cbbd9fff8dfb9d51
4
+ data.tar.gz: d4bcb2bf851d386b3ec65d88698fc080f8e7f53480c330ac5fe1771f10b27ebc
5
5
  SHA512:
6
- metadata.gz: 118da3d69ff9ad1a54374b2107dfe9279c51aa3338c66ef3be1c42935d3cd8d9e16aff174afeebe566e4e523d8d2bc62ff40a79d49e398aceaedea80b0c81b65
7
- data.tar.gz: 511e16514e4a8320a0e56e028f36b9980666ac677f0f3bafcce87a08c80e15d133b6e21b63ca186f390f496d195a9e553c1a5c41214a0962a33919bce8a2aee0
6
+ metadata.gz: 63bf32f6ed28bd025937eb83d6135f73af4d0070dc747d2da6cc624bdb55e674721fecc11ffbb6c52b427a3d5115fe02853cc4917c3a1ba1ae3d3476f80fddd2
7
+ data.tar.gz: 872bda8c032763f2e4ff052f439b8396a01abe7264479dd06b45d1209f711cb2a88ed9671499bc56759778797892652035e919d146d6a081a37b9131208fbf66
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IknowViewModels
4
- VERSION = '3.0.1'
4
+ VERSION = '3.0.2'
5
5
  end
@@ -22,14 +22,14 @@ module ViewModel::ActiveRecord::CollectionNestedController
22
22
  extend ActiveSupport::Concern
23
23
  include ViewModel::ActiveRecord::NestedControllerBase
24
24
 
25
- def index_associated(scope: nil, serialize_context: new_serialize_context)
26
- show_association(scope: scope, serialize_context: serialize_context)
25
+ def index_associated(scope: nil, serialize_context: new_serialize_context, &block)
26
+ show_association(scope: scope, serialize_context: serialize_context, &block)
27
27
  end
28
28
 
29
29
  # Deserialize items of the associated type and associate them with the owner,
30
30
  # replacing previously associated items.
31
- def replace(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context)
32
- write_association(serialize_context: serialize_context, deserialize_context: deserialize_context)
31
+ def replace(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context, &block)
32
+ write_association(serialize_context: serialize_context, deserialize_context: deserialize_context, &block)
33
33
  end
34
34
 
35
35
  def disassociate_all(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context)
@@ -61,6 +61,7 @@ module ViewModel::ActiveRecord::CollectionNestedController
61
61
  ViewModel::Callbacks.wrap_serialize(owner_view, context: serialize_context) do
62
62
  child_context = owner_view.context_for_child(association_name, context: serialize_context)
63
63
  ViewModel.preload_for_serialization(assoc_view, serialize_context: child_context)
64
+ assoc_view = yield(assoc_view) if block_given?
64
65
  prerender_viewmodel(assoc_view, serialize_context: child_context)
65
66
  end
66
67
  end
@@ -45,10 +45,8 @@ module ViewModel::ActiveRecord::Controller
45
45
  view = nil
46
46
  pre_rendered = viewmodel_class.transaction do
47
47
  view = viewmodel_class.deserialize_from_view(update_hash, references: refs, deserialize_context: deserialize_context)
48
-
49
- view = yield(view) if block_given?
50
-
51
48
  ViewModel.preload_for_serialization(view, serialize_context: serialize_context)
49
+ view = yield(view) if block_given?
52
50
  prerender_viewmodel(view, serialize_context: serialize_context)
53
51
  end
54
52
  render_json_string(pre_rendered)
@@ -41,6 +41,7 @@ module ViewModel::ActiveRecord::NestedControllerBase
41
41
  ViewModel::Callbacks.wrap_serialize(owner_view, context: serialize_context) do
42
42
  child_context = owner_view.context_for_child(association_name, context: serialize_context)
43
43
  ViewModel.preload_for_serialization(association_view, serialize_context: child_context)
44
+ association_view = yield(association_view) if block_given?
44
45
  prerender_viewmodel(association_view, serialize_context: child_context)
45
46
  end
46
47
  end
@@ -20,12 +20,12 @@ module ViewModel::ActiveRecord::SingularNestedController
20
20
  extend ActiveSupport::Concern
21
21
  include ViewModel::ActiveRecord::NestedControllerBase
22
22
 
23
- def show_associated(scope: nil, serialize_context: new_serialize_context, deserialize_context: new_deserialize_context)
24
- show_association(scope: scope, serialize_context: serialize_context)
23
+ def show_associated(scope: nil, serialize_context: new_serialize_context, deserialize_context: new_deserialize_context, &block)
24
+ show_association(scope: scope, serialize_context: serialize_context, &block)
25
25
  end
26
26
 
27
- def create_associated(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context)
28
- write_association(serialize_context: serialize_context, deserialize_context: deserialize_context)
27
+ def create_associated(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context, &block)
28
+ write_association(serialize_context: serialize_context, deserialize_context: deserialize_context, &block)
29
29
  end
30
30
 
31
31
  def destroy_associated(serialize_context: new_serialize_context, deserialize_context: new_deserialize_context)
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.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - iKnow Team