chainit 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 +4 -4
- data/README.md +1 -1
- data/lib/chain_it/version.rb +1 -1
- data/lib/chain_it.rb +23 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c74ac4b8fd343c0102004f3c6f36b9e96a5d4e0
|
4
|
+
data.tar.gz: 6b5b8dca91e216e026b414d4efadfc2689acb9f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ad71c4a97c6e1ce038b4d15eab7fe7a3c310cabb6bdc1c84d6b7a2b44751a316008a06b15b354ea4849f56b7533a5af73431ae05e321e2eb41ea1d38c5e8fd
|
7
|
+
data.tar.gz: 32fd4e691d7db94f937c2fa71f524f24070eb17917c1d43459434de47e1a52eb02bc1b8196d47ce6e40062ff855a2dd2dc001e14bfb5503354b6439d6f00584a
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# ChainIt
|
2
|
-
[![CircleCI](https://circleci.com/gh/spark-solutions/
|
2
|
+
[![CircleCI](https://circleci.com/gh/spark-solutions/chain_it/tree/master.svg?style=svg&circle-token=3bb16aef0dbcbe7fd18500376a110bd6cedf668a)](https://circleci.com/gh/spark-solutions/ChainIt/tree/master)
|
3
3
|
|
4
4
|
## Description
|
5
5
|
This provides the tool which is implementation of railway-oriented programming concept itself
|
data/lib/chain_it/version.rb
CHANGED
data/lib/chain_it.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class ChainIt
|
2
|
+
INVALID_RESULT_MSG = "ChainIt#chain block must return both #value and #failure? aware object.\n Check documentation: https://github.com/spark-solutions/chain_it#usage"
|
3
|
+
|
2
4
|
def chain
|
3
5
|
if @skip_next
|
4
6
|
@skip_next = false
|
@@ -7,20 +9,21 @@ class ChainIt
|
|
7
9
|
|
8
10
|
return self if @skip
|
9
11
|
@skip_next = false
|
10
|
-
|
11
|
-
@
|
12
|
+
|
13
|
+
@result = yield result_value
|
14
|
+
@skip = true if result_failure?
|
12
15
|
self
|
13
16
|
end
|
14
17
|
|
15
18
|
def skip_next
|
16
19
|
return self if @skip
|
17
|
-
@skip_next = yield
|
20
|
+
@skip_next = yield result_value
|
18
21
|
self
|
19
22
|
end
|
20
23
|
|
21
24
|
def on_error
|
22
25
|
return self unless @skip
|
23
|
-
yield
|
26
|
+
yield result_value
|
24
27
|
@skip = false
|
25
28
|
self
|
26
29
|
end
|
@@ -28,6 +31,22 @@ class ChainIt
|
|
28
31
|
def result
|
29
32
|
@result
|
30
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def handle_wrong_result_api
|
38
|
+
yield
|
39
|
+
rescue NoMethodError
|
40
|
+
raise StandardError.new INVALID_RESULT_MSG
|
41
|
+
end
|
42
|
+
|
43
|
+
def result_value
|
44
|
+
handle_wrong_result_api { @result&.value }
|
45
|
+
end
|
46
|
+
|
47
|
+
def result_failure?
|
48
|
+
handle_wrong_result_api { @result.failure? }
|
49
|
+
end
|
31
50
|
end
|
32
51
|
|
33
52
|
require 'chain_it/version'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chainit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- btolarz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-08-
|
12
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|