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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de0f81ebb1cb01cf055f9a164330a9650a9c17f5a75a544299681124962ac8a0
|
4
|
+
data.tar.gz: 77806d883a0f98b57047c0a5d5ec143b737544dd34bf63d208abb2d76ccd4ca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
-
|
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(
|
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
|
-
|
16
|
-
Success(prev_result)
|
14
|
+
Success(args.first)
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/use_cases/version.rb
CHANGED