usecasing 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/usecasing/base.rb +7 -2
- data/lib/usecasing/version.rb +1 -1
- data/spec/usecase_base_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmM1ZGY4MDNmYWM4MTA5MTAwN2Y5N2I1MGQ3MmRlNjY1MzM0ODliYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTIzNmZjZmQ1ZjJiNGYwMGZjNzIzNTJiOTRjYTA1YWE5NWY5MzA1Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTIxMjg4OWRmYTI1MmIzYWQ2NWNiYzQ3YTFiMmMyNjBjMmM2NzZkYmViMzcw
|
10
|
+
Yjg3NWNjYjQyOWJjODhjODFlZTMxNzRkNWM5MjRlMzgzNjA3NTgzZmI1NTRm
|
11
|
+
NDRiMmUyMzQ1ZTNmNjg4NTY4MzRlZGFhMWJmNjIzMGJlMDY0Nzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmQ2OGE3MTJlMjJlNDRkZjQ0YjBmOWI0MTAzYTYzNmJhYTkxYzU0YjhhZjgz
|
14
|
+
MGRhMGIxZWIxMWQwNDA4MzY5ZWJhNzZiZGI2MTM1MWZjZjViNzJhYTZjNWM3
|
15
|
+
OGVlNDFhNTgwY2RiMGU4OGVjYjk0NjA1YzMyNmFlNzg0NWIwODA=
|
data/lib/usecasing/base.rb
CHANGED
@@ -20,8 +20,12 @@ module UseCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def perform(ctx = { })
|
23
|
-
tx(ExecutionOrder.run(self), ctx) do |usecase, context|
|
24
|
-
usecase.new(context)
|
23
|
+
tx(ExecutionOrder.run(self), ctx) do |usecase, context|
|
24
|
+
instance = usecase.new(context)
|
25
|
+
instance.tap do | me |
|
26
|
+
me.before
|
27
|
+
me.perform
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
@@ -58,6 +62,7 @@ module UseCase
|
|
58
62
|
@context = context
|
59
63
|
end
|
60
64
|
|
65
|
+
def before; end
|
61
66
|
def perform; end
|
62
67
|
def rollback; end
|
63
68
|
|
data/lib/usecasing/version.rb
CHANGED
data/spec/usecase_base_spec.rb
CHANGED
@@ -268,4 +268,26 @@ describe UseCase::Base do
|
|
268
268
|
|
269
269
|
end
|
270
270
|
|
271
|
+
|
272
|
+
describe '#before' do
|
273
|
+
|
274
|
+
it 'calls "before" method before perform' do
|
275
|
+
BeforeUsecasing = Class.new(UseCase::Base) do
|
276
|
+
|
277
|
+
def before
|
278
|
+
context.before = true
|
279
|
+
end
|
280
|
+
|
281
|
+
def perform
|
282
|
+
raise 'Should be called' unless context.before
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
expected = BeforeUsecasing.perform
|
287
|
+
expect(expected.before).to eql(true)
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
271
293
|
end
|
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.6
|
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-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|