use_cases 0.2.5 → 0.2.7

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: cf8f3d237d63199c6af9da931fa275833b6cadf3378548d95208f7aa11bc7a49
4
- data.tar.gz: bc428dd162cfa152966ffb1eae6273796649baa4f8a702fe43887ce05fab26c6
3
+ metadata.gz: de0f81ebb1cb01cf055f9a164330a9650a9c17f5a75a544299681124962ac8a0
4
+ data.tar.gz: 77806d883a0f98b57047c0a5d5ec143b737544dd34bf63d208abb2d76ccd4ca5
5
5
  SHA512:
6
- metadata.gz: 3fef9fde7da990fd80b02754bc2f63d5550fdbb856044dd9ee8a4bdb392be814807d3ff345b5c5cae609572b10b00c57512b3b37bc3cc8812fb989726a706570
7
- data.tar.gz: 1c5acb9f5f82918d6f79eed927d346f0bd165bb66dd3e0b6f673d8419bc34faa6b991d8066df7080ebdaf75170801c0363cacb4d6463305131e1d520bb4afbc5
6
+ metadata.gz: 0254b038f7557a64bf7393a2e25756fbb4d39974a04498a866f163eb7346e77a91607964df9c08a22885c3fcb234cba2e326a8d2212ba2f8330ba0ab4bc31f49
7
+ data.tar.gz: 334acafe1e3032133470fdd38403d97d6c2ce3eb51b08e5b0aa0542e6a2e409aa094e777e34f605b7d27c77ca226bcb127b8e2e9c987474a63877589ab8392bc
@@ -14,18 +14,24 @@ module UseCases
14
14
  end
15
15
 
16
16
  def deserialize_step_arguments(args)
17
- args.map { |arg| arg.is_a?(Hash) && arg.delete("_serialized_by_use_case") ? arg.deserialize : arg }
17
+ args.map do |arg|
18
+ if arg.is_a?(Hash) && arg.delete("_serialized_by_use_case")
19
+ arg.delete('_class').constantize.new(arg)
20
+ else
21
+ arg
22
+ end
23
+ end
18
24
  end
19
25
 
20
26
  def self.serialize_step_arguments(args)
21
- args.select.with_index do |arg, index|
27
+ args.select.map.with_index do |arg, index|
22
28
  ActiveJob::Arguments.send(:serialize_argument, arg)
23
-
29
+ false
24
30
  rescue ActiveJob::SerializationError => _e
25
- arg.serialize.merge("_serialized_by_use_case" => true)
31
+ args = arg.serialize.merge("_serialized_by_use_case" => true, "_class" => arg.class.name)
26
32
 
27
33
  rescue NoMethodError => _e
28
- puts "[WARNING] #{arg.class} (index = #{index})" \
34
+ puts "[WARNING] #{arg} of class (#{arg.clas}) (index = #{index})" \
29
35
  "is not serializable and does not repond to #serialize and will be ignored."
30
36
  false
31
37
  end
@@ -9,13 +9,13 @@ module UseCases
9
9
 
10
10
  def do_call(*args)
11
11
  result = super(*args)
12
- prev_result = previous_step_result.value
12
+
13
13
  raise InvalidReturnValue, "The return value should not be a Monad." if result.is_a?(Dry::Monads::Result)
14
14
 
15
15
  failure_code = options[:failure] || :check_failure
16
16
  failure_message = options[:failure_message] || "Failed"
17
17
 
18
- result ? Success(prev_result) : Failure([failure_code, failure_message])
18
+ result ? Success(args.first) : Failure([failure_code, failure_message])
19
19
  end
20
20
  end
21
21
  end
@@ -9,11 +9,9 @@ module UseCases
9
9
 
10
10
  def do_call(*args)
11
11
  result = super(*args)
12
- rescue StandardError => _e
13
12
  raise InvalidReturnValue, "For a tee step, a Monad will have no effect." if result.is_a?(Dry::Monads::Result)
14
13
 
15
- prev_result = previous_step_result.value
16
- Success(prev_result)
14
+ Success(args.first)
17
15
  end
18
16
  end
19
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UseCases
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_cases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ring Twice