usecasing 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +38 -0
- data/lib/usecasing/context.rb +2 -1
- data/lib/usecasing/version.rb +1 -1
- data/spec/context_spec.rb +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGM2NzViMTVhZmQxYzc1ODNmNmI4OTg0Mzk0NjgyMjI3OWJmN2I1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDAyN2M0Y2NkMTMxNDA3NzVhYTRmOGIyOGQ2YjU3YWI3MTk3ZjQ2Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmRiNTI4YjY3MWE4MGRhY2JhZTVhNGE2YmE5NDk5NWM0NmU2ZDIzMWRjYWUw
|
10
|
+
MGU5NzVjMTUxZmVlYmEyNTA4OWU2ODRiMTdhOGE0MDI1OWRmMDc1NTM4OTBi
|
11
|
+
MmRiOWVlYTQ4ZmMwMjhhZTRhMWM3MzZjODExNTMwNTU2MjM5YTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWI4ZTVlYjcxMDJkMWI3ZDhmZjE3Yzk3MjljYmIyMjVlODk4OTg1NDcyNjRm
|
14
|
+
ZTkwNjE1YTE5ODFmZTMwYzE5YTA2OTMzNTc5OTc3NjRiNmMxOGQwMWI1MmIx
|
15
|
+
N2UxNTc4NzVkNjFkY2U1MDRmMDVlN2FiNDljYTJmYzRlN2VmZTY=
|
data/README.md
CHANGED
@@ -141,6 +141,44 @@ Oww, yeah, let's notify the customer
|
|
141
141
|
end
|
142
142
|
````
|
143
143
|
|
144
|
+
#### Stopping the UseCase dependencies Flow
|
145
|
+
|
146
|
+
There are 2 ways to stop the dependency flow.
|
147
|
+
- stop! ( stop the flow without marking the usecase with error )
|
148
|
+
- failure ( stop the flow but mark the usecase with errors )
|
149
|
+
|
150
|
+
|
151
|
+
Imagine a Read Through Cache Strategy.
|
152
|
+
How can we stop the usecase flow without marking as failure ?
|
153
|
+
|
154
|
+
````
|
155
|
+
class ReadThrough < UseCase::Base
|
156
|
+
depends MemCacheReader, DataBaseReader, MemCacheWriter
|
157
|
+
end
|
158
|
+
|
159
|
+
class MemCacheReader < UseCase::Base
|
160
|
+
def perform
|
161
|
+
context.data = CacheAdapter.read('key')
|
162
|
+
stop! if context.data
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class DataBaseReader < UseCase::Base
|
167
|
+
def perform
|
168
|
+
context.data = DataBase.find('key')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
class MemCacheWriter < UseCase::Base
|
173
|
+
def perform
|
174
|
+
CacheAdapter.write('key', context.data);
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
````
|
179
|
+
|
180
|
+
|
181
|
+
|
144
182
|
|
145
183
|
Let me know what do you think about it.
|
146
184
|
|
data/lib/usecasing/context.rb
CHANGED
@@ -5,7 +5,7 @@ module UseCase
|
|
5
5
|
class Errors
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@errors = Hash.new
|
8
|
+
@errors = Hash.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def all(delimiter= ", ", &block)
|
@@ -22,6 +22,7 @@ module UseCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def push(key, value)
|
25
|
+
@errors[key.to_sym] = [] unless @errors[key.to_sym]
|
25
26
|
@errors[key.to_sym].push(value)
|
26
27
|
end
|
27
28
|
|
data/lib/usecasing/version.rb
CHANGED
data/spec/context_spec.rb
CHANGED
@@ -101,5 +101,14 @@ describe UseCase::Context do
|
|
101
101
|
expect(errors_keys).to eql([:error_1, :error_2])
|
102
102
|
expect(errors_values).to eql([["this is the first error"], ["this is a second error"]])
|
103
103
|
end
|
104
|
+
|
105
|
+
# https://github.com/tdantas/usecasing/issues/4
|
106
|
+
it "does not mark failure when access key that does not exist" do
|
107
|
+
ctx = described_class.new
|
108
|
+
expect(ctx.success?).to be_true
|
109
|
+
ctx[:key]
|
110
|
+
expect(ctx.success?).to be_true
|
111
|
+
end
|
112
|
+
|
104
113
|
end
|
105
114
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usecasing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Dantas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.2.
|
112
|
+
rubygems_version: 2.2.2
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: UseCase Driven Approach
|