usecasing_validations 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGUyMzJjMTM2MDg0NWFhNzBhNjI2MWZjODc2NmUzYjA1MDlmMDI5Zg==
4
+ Yzg4YWJiZjk3M2FhODgyNDUxNWQxY2ZhZDExNDk0ZTIyZWFmMWYxNw==
5
5
  data.tar.gz: !binary |-
6
- NWEyZTM5MTVlNjc3MThkYmUyOTg0NmE1MGUxYTA1ZjVmNzg2MTlkNQ==
6
+ OGEyOWQ5MmMxMGU1MTRhMzUxNTQ3MTNlNDczZmYyMDAxMWM4MDVhYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmExMzUyN2U1OWI0NWUwOGVjOGY3YmI1NjMwMjhhYjcwN2RjYWM4ZWQ5MzE2
10
- OTJkMjcyMmFiZjc5MmE1YWUwNWIxMjUzYzExZmVjZWIzZmUxMjQyZTk1ZDAy
11
- N2I5ODk2MTBiODkxYWEwZTM1ODA1YzA5YjUwYWE3Y2YxNjRlNTg=
9
+ YjIxOTc5NWQ4ODE4MDUzMzUyN2M2OTZjMjM0M2U2ODhkMDY5YjZlNjE4NzE0
10
+ YmE3MzdhMTNmZjIwOGNlMDAxOThkNGUxNjBhNjc1MDcyZTgwODNjYjBlNTQ4
11
+ YzFmMmY4ZjRkYjU2MmZkNTdmYmU1YTY3YTRiODE3M2ZjOTQ4Mzc=
12
12
  data.tar.gz: !binary |-
13
- MzZhZTk0MWM4Y2IxZWQ1YzI3ZmRmNzcxMTY2MzRjZjAxNzE4Y2E4ZDliMjA1
14
- NzIwOWQ0OTBhYmVkZjFmZDBlODc2MmU1Yjg3NTQ5MzFjOWVkZTZlNGUzZDhh
15
- MmY1NzY1OGJiNjEzNjY0NGVjMzE0MDZmYmUyMDk3MDE3YTQ5MDY=
13
+ NzEyN2NiZDI3NDM5MDMwNjJlNWVlNmNiYjdiZTVjYTc4NWY5MjhjNzUzNzUz
14
+ ZmUwOGZiOGUxMzU3ZTc0M2Q3NTI4ZWY4YmZhYjliMzZlYjFlMTlmYjAzOTJl
15
+ YzgyNWZlNjUzNzM0NzI0ZWMxYTc1YjM3ZjYwODgyOWRhYzgzZmY=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usecasing_validations (0.5.0)
4
+ usecasing_validations (0.5.1)
5
5
  usecasing (= 0.1.4)
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module UseCaseValidations
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -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
 
@@ -16,9 +16,9 @@ module Group
16
16
 
17
17
  end
18
18
 
19
- class ValidateDependsAll < UseCase::DependsAll
19
+ class ValidateDependsAll < UseCase::Base
20
20
 
21
- depends ValidatePostTitle, ValidatePostBody
21
+ depends_all ValidatePostTitle, ValidatePostBody
22
22
 
23
23
  end
24
24
  end
@@ -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.0
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