transflow 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/transflow/publisher.rb +37 -0
- data/lib/transflow/version.rb +1 -1
- 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: 191a70cd5a82b31910a2f10b64e5058ae376f729
|
4
|
+
data.tar.gz: d7ad841f948925604c5b0c176c86c66c9d4a05cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c407713885bd8d348fbdbd6ea3c79547d82047dd20d989da5a83f3b7f1aba0134dacb1bffd57ba73385de1c13ab75735652659c99ca203118dafd888da110a
|
7
|
+
data.tar.gz: dc06637017c57a11ed654b1361490a98269aeeb1cb616751cc048b42ec67ea14195665b3582360889986605b69af8859224d4d073ce8b122de262c359fe71105
|
data/CHANGELOG.md
CHANGED
data/lib/transflow/publisher.rb
CHANGED
@@ -8,11 +8,48 @@ module Transflow
|
|
8
8
|
|
9
9
|
attr_reader :op
|
10
10
|
|
11
|
+
class Curried < Publisher
|
12
|
+
attr_reader :publisher
|
13
|
+
|
14
|
+
attr_reader :arity
|
15
|
+
|
16
|
+
attr_reader :curry_args
|
17
|
+
|
18
|
+
def initialize(publisher, curry_args = [])
|
19
|
+
@publisher = publisher
|
20
|
+
@arity = publisher.arity
|
21
|
+
@curry_args = curry_args
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(*args)
|
25
|
+
all_args = curry_args + args
|
26
|
+
|
27
|
+
if all_args.size == arity
|
28
|
+
publisher.call(*all_args)
|
29
|
+
else
|
30
|
+
self.class.new(publisher, all_args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def subscribe(*args)
|
35
|
+
publisher.subscribe(*args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
11
39
|
def initialize(name, op)
|
12
40
|
@name = name
|
13
41
|
@op = op
|
14
42
|
end
|
15
43
|
|
44
|
+
def curry
|
45
|
+
raise "can't curry publisher where operation arity is < 0" if arity < 0
|
46
|
+
Curried.new(self)
|
47
|
+
end
|
48
|
+
|
49
|
+
def arity
|
50
|
+
op.is_a?(Proc) ? op.arity : op.method(:call).arity
|
51
|
+
end
|
52
|
+
|
16
53
|
def call(*args)
|
17
54
|
result = op.call(*args)
|
18
55
|
broadcast(:"#{name}_success", result)
|
data/lib/transflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: transproc
|