civil 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 974e17fa57368ecf766599d101e4288fe9f2e3f5
4
- data.tar.gz: d074989955d7a0833356904a99c977eb0b200b44
3
+ metadata.gz: 1bbae03b7c5bb563b1b6e728fefd604be43ba5fe
4
+ data.tar.gz: 6d2fe1f7674b416b0d4341dcd06c9e2b1ee96215
5
5
  SHA512:
6
- metadata.gz: 66e2a26d825c4a69a5031987d8098a30485df6b6814d09d96807f24f5448496e233041fa1f00ebfbb4c5168cd03038152efcc1b15939ab7b9c97fd9f51d6cff8
7
- data.tar.gz: e838820cb4a0b7f908d785fdc0a48b9cdbc3c58974467ca7c7d7740ea98c6c78a0695746e6395045410c2d75e8728e75faf8fb507e61a1a1f6aae2385449eb83
6
+ metadata.gz: 53b669f68cbc9a2fb46d55b30f35e188ffbc9837efa5ce15491bdd527f8b9aa2e06193bf21e8b802fee68e6ea3a10f4b2eb1100d1d04dde60e4a6153d3c0c6dc
7
+ data.tar.gz: 79ab0143ea4e81584384503ad57024dfd3707b3acc96f720ff682042960928cb69f04021af8946ef50a664d9aef9c190719f711e269bf40ce5d7af1b90ed686f
data/CHANGELOG.md CHANGED
@@ -6,10 +6,26 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- ## [1.0.0] - 2016-11-30
9
+ ## [1.1.0] - 2016-12-2
10
10
  ### Added
11
- - More robust specs for Civil::Result#add_meta and Civil::Result#add_condition
11
+ - You can now run services by passing in blocks to `call`. The service will
12
+ only run the methods in the block:
13
+
14
+ ```ruby
15
+ MyService.call do
16
+ step_one
17
+ # Normally, step two would get run, but let's skip it this time
18
+ # step_two
19
+ step_three
20
+
21
+ result
22
+ end
23
+ ```
12
24
 
25
+ If you've already defined steps inside the service class in a `service`
26
+ block, that's OK, the passed-in block will override.
27
+
28
+ ## [1.0.0] - 2016-11-30
13
29
  ### Changed
14
30
  - Result conditions and meta now store keyed arrays of data instead of key/value pairs
15
31
 
data/README.md CHANGED
@@ -109,6 +109,26 @@ result = MetadataExample.call doodad: doodad
109
109
  result.meta # { length: 12.5 }
110
110
  ```
111
111
 
112
+ ### Overriding the service block
113
+
114
+ You can override the steps defined within your service class' `service` block
115
+ by passing a block to `call`:
116
+
117
+ ```ruby
118
+ class MyService
119
+ service do
120
+ step_one
121
+ step_two
122
+ result
123
+ end
124
+
125
+ ...
126
+ end
127
+
128
+ # The following will skip step_two
129
+ result = MyService.call { step_one; result; }
130
+ ```
131
+
112
132
  ## Development
113
133
 
114
134
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/civil/service.rb CHANGED
@@ -24,9 +24,9 @@ module Civil
24
24
  # else
25
25
  # ...
26
26
  # end
27
- def call(params = {})
27
+ def call(params = {}, &block)
28
28
  service = new(params)
29
- data = service._run
29
+ data = (block ? service.instance_eval(&block) : service._run)
30
30
 
31
31
  Civil::Result.new(data, service._conditions, service._meta)
32
32
  end
data/lib/civil/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Civil
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civil
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ersin Akinci
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2016-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler