usecasing_validations 0.5.0 → 0.5.1
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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/usecasing_validations/version.rb +1 -1
- data/lib/usecasing_validations.rb +31 -1
- data/spec/support/usecases/validate_depends_all.rb +2 -2
- data/spec/usecasing/validate_depends_all_spec.rb +1 -1
- metadata +1 -2
- data/lib/usecasing/depends_all.rb +0 -21
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Yzg4YWJiZjk3M2FhODgyNDUxNWQxY2ZhZDExNDk0ZTIyZWFmMWYxNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGEyOWQ5MmMxMGU1MTRhMzUxNTQ3MTNlNDczZmYyMDAxMWM4MDVhYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjIxOTc5NWQ4ODE4MDUzMzUyN2M2OTZjMjM0M2U2ODhkMDY5YjZlNjE4NzE0
|
10
|
+
YmE3MzdhMTNmZjIwOGNlMDAxOThkNGUxNjBhNjc1MDcyZTgwODNjYjBlNTQ4
|
11
|
+
YzFmMmY4ZjRkYjU2MmZkNTdmYmU1YTY3YTRiODE3M2ZjOTQ4Mzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzEyN2NiZDI3NDM5MDMwNjJlNWVlNmNiYjdiZTVjYTc4NWY5MjhjNzUzNzUz
|
14
|
+
ZmUwOGZiOGUxMzU3ZTc0M2Q3NTI4ZWY4YmZhYjliMzZlYjFlMTlmYjAzOTJl
|
15
|
+
YzgyNWZlNjUzNzM0NzI0ZWMxYTc1YjM3ZjYwODgyOWRhYzgzZmY=
|
data/Gemfile.lock
CHANGED
@@ -15,8 +15,38 @@ require "usecasing_validations/validations/uniqueness"
|
|
15
15
|
|
16
16
|
|
17
17
|
module UseCase
|
18
|
+
|
19
|
+
class Base
|
20
|
+
|
21
|
+
def self.depends_all(*deps)
|
22
|
+
@dependencies ||= []
|
23
|
+
@dependencies.push(*deps)
|
24
|
+
ignored_dependencies.push(*deps)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.ignored_dependencies
|
28
|
+
@ignored_dependencies ||= []
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.not_ignored(usecase)
|
32
|
+
!ignored_dependencies.include?(usecase)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.tx(execution_order, context)
|
36
|
+
ctx = Context.new(context)
|
37
|
+
executed = []
|
38
|
+
execution_order.each do |usecase|
|
39
|
+
break if not_ignored(usecase) && !ctx.success?
|
40
|
+
executed.push(usecase)
|
41
|
+
yield usecase, ctx
|
42
|
+
end
|
43
|
+
rollback(executed, ctx) unless ctx.success?
|
44
|
+
ctx
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
18
49
|
autoload :Validator, 'usecasing/validator'
|
19
|
-
autoload :DependsAll, 'usecasing/depends_all'
|
20
50
|
end
|
21
51
|
|
22
52
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Group::ValidateDependsAll do
|
4
4
|
|
5
|
-
it "Validating multiple UseCase:Validators at the same time without one interrupting the other" do
|
5
|
+
it "Validating multiple UseCase:Validators at the same time without one interrupting the other", current: true do
|
6
6
|
|
7
7
|
post = RubyPost.new
|
8
8
|
context = Group::ValidateDependsAll.perform(post: post)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usecasing_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Gonçalves
|
@@ -95,7 +95,6 @@ files:
|
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
-
- lib/usecasing/depends_all.rb
|
99
98
|
- lib/usecasing/validator.rb
|
100
99
|
- lib/usecasing_validations.rb
|
101
100
|
- lib/usecasing_validations/custom_validator.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module UseCase
|
2
|
-
|
3
|
-
class DependsAll < Base
|
4
|
-
|
5
|
-
private ######################### PRIVATE ######################
|
6
|
-
|
7
|
-
def self.tx(execution_order, context)
|
8
|
-
ctx = Context.new(context)
|
9
|
-
executed = []
|
10
|
-
execution_order.each do |usecase|
|
11
|
-
# break unless ctx.success?
|
12
|
-
executed.push(usecase)
|
13
|
-
yield usecase, ctx
|
14
|
-
end
|
15
|
-
rollback(executed, ctx) unless ctx.success?
|
16
|
-
ctx
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|