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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWY3MzNkMWQ1ZDU2MDJkMWZjZTJjY2NjODBhMzkzZjU1MTlkYmUxMg==
4
+ YmM1ZGY4MDNmYWM4MTA5MTAwN2Y5N2I1MGQ3MmRlNjY1MzM0ODliYQ==
5
5
  data.tar.gz: !binary |-
6
- ZjM1YzFhZGM2MWQ4ZjkxM2JhYTk0ZmU4YjAyYjk5MGEwZDNiZmIyMg==
6
+ OTIzNmZjZmQ1ZjJiNGYwMGZjNzIzNTJiOTRjYTA1YWE5NWY5MzA1Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDg1OTBlNDhlNTAxZDU3MWViNTZjNTYyMTJiNDJlNzE3Y2MzNTdiNWJiNjc3
10
- OWMxMzY5MzM0ZDkwNTdjNThlOWM2M2I0MDVkYWNlMWVjYjU2YzgwY2ZhNDU4
11
- Mzg1ZGQzMmVhNzg1M2ZhNmQ2MjljZGE1MDljODRmNjAzYjBiMGQ=
9
+ OTIxMjg4OWRmYTI1MmIzYWQ2NWNiYzQ3YTFiMmMyNjBjMmM2NzZkYmViMzcw
10
+ Yjg3NWNjYjQyOWJjODhjODFlZTMxNzRkNWM5MjRlMzgzNjA3NTgzZmI1NTRm
11
+ NDRiMmUyMzQ1ZTNmNjg4NTY4MzRlZGFhMWJmNjIzMGJlMDY0Nzg=
12
12
  data.tar.gz: !binary |-
13
- NDYyNjhhNTM4NmFjMWU4Nzg1ZTQwZjg1NmEwNmY0YmRiMTkzZDFmYmJjN2Qz
14
- YjNkODcxODk2MGZhYzM2OWMwYmJjNGMyYmE0YjE1YTE4NjczYWM1MTQ3NjA1
15
- YjY5MTJhYjRjMTliNWMwYzhkZjRmZDdmOGM1NDI2NjM3NWRhZGE=
13
+ ZmQ2OGE3MTJlMjJlNDRkZjQ0YjBmOWI0MTAzYTYzNmJhYTkxYzU0YjhhZjgz
14
+ MGRhMGIxZWIxMWQwNDA4MzY5ZWJhNzZiZGI2MTM1MWZjZjViNzJhYTZjNWM3
15
+ OGVlNDFhNTgwY2RiMGU4OGVjYjk0NjA1YzMyNmFlNzg0NWIwODA=
@@ -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).perform
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
 
@@ -1,3 +1,3 @@
1
1
  module Usecasing
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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.5
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-02-04 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec