callchain 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/lib/callchain.rb +8 -0
- data/lib/callchain/version.rb +1 -1
- data/test/bind_test.rb +19 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bc6bb09b89dfb7e2aee6547fc8f028d394add77
|
4
|
+
data.tar.gz: adfbbf6e6b4cc55e59c894d8c0ba678fb121192c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97329693c349a921c2030225f3124c04441745ae7dfd880ebdbeb5c6f2275dedf19c06d20b4aae0d2a4e396abbe87c9cb8e625aa3d8e2a35d169f1591d79e0a2
|
7
|
+
data.tar.gz: 53e1a2775715457385ff6ef33e2b1528869ea035f5e3c3383ad758b3cd0e1a2ac2c50d4c742e104a188ffa3b8656f20c56035f533eb091d6afa9de395692f494
|
data/README.md
CHANGED
@@ -72,6 +72,28 @@ Compose a CallChain of call chains because it exports `::call(object)`
|
|
72
72
|
CompositeCallChain.call(Object.new)
|
73
73
|
```
|
74
74
|
|
75
|
+
## CallChain::bind
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
class WrapToI
|
79
|
+
extend CallChain
|
80
|
+
use CallChain[:to_i]
|
81
|
+
end
|
82
|
+
|
83
|
+
WrapToI.call('1')
|
84
|
+
# => 1
|
85
|
+
```
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
class WrapToI
|
89
|
+
extend CallChain
|
90
|
+
use CallChain.bind(:+, 1)
|
91
|
+
end
|
92
|
+
|
93
|
+
WrapToI.call(1)
|
94
|
+
# => 2
|
95
|
+
```
|
96
|
+
|
75
97
|
## Contributing
|
76
98
|
|
77
99
|
1. Fork it ( http://github.com/<my-github-username>/callchain/fork )
|
data/lib/callchain.rb
CHANGED
data/lib/callchain/version.rb
CHANGED
data/test/bind_test.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'callchain'
|
3
|
+
|
4
|
+
|
5
|
+
class BindTest < Minitest::Test
|
6
|
+
def test_calls_method
|
7
|
+
chain_class = Class.new
|
8
|
+
chain_class.extend(CallChain)
|
9
|
+
chain_class.use CallChain[:to_i]
|
10
|
+
assert_equal 1, chain_class.call('1')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_binds_args
|
14
|
+
chain_class = Class.new
|
15
|
+
chain_class.extend(CallChain)
|
16
|
+
chain_class.use CallChain.bind(:+, 1)
|
17
|
+
assert_equal 2, chain_class.call(1)
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: callchain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- csquared
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- callchain.gemspec
|
54
54
|
- lib/callchain.rb
|
55
55
|
- lib/callchain/version.rb
|
56
|
+
- test/bind_test.rb
|
56
57
|
- test/callchain_test.rb
|
57
58
|
homepage: ''
|
58
59
|
licenses:
|
@@ -79,4 +80,5 @@ signing_key:
|
|
79
80
|
specification_version: 4
|
80
81
|
summary: Simple, composable call chains
|
81
82
|
test_files:
|
83
|
+
- test/bind_test.rb
|
82
84
|
- test/callchain_test.rb
|