rails-workflow 1.4.1.3 → 1.4.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +0 -1
- data/lib/workflow/callbacks/transition_callback_wrapper.rb +16 -13
- data/lib/workflow/transition_context.rb +4 -0
- data/lib/workflow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebaf58ab065f71da4435f23776e611a91a3db506
|
4
|
+
data.tar.gz: 7c2852bd1e597559436ab141a3a66c8840425589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9d5cdca15811c52c65974a329e810bf8712a3caa16e159a9661393126ff0fecf18c052294d4896b40e0f555de7429acc2217595a21a6f61801ecfbbfbfa0bd
|
7
|
+
data.tar.gz: adb0500c94fef7a0b0f8d7b01bb724dd7d6feb5161c3ee254e38d6e3e5ad5cafa7bcc7eac33ec5725f76e291d9a24366c516af7a9df823b6098a98f4e4157374
|
data/bin/console
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Workflow
|
2
2
|
module Callbacks
|
3
3
|
class TransitionCallbackWrapper
|
4
|
-
attr_reader :callback_type, :
|
5
|
-
def initialize(callback_type,
|
4
|
+
attr_reader :callback_type, :inner_procedure
|
5
|
+
def initialize(callback_type, inner_procedure)
|
6
6
|
@callback_type = callback_type
|
7
|
-
@
|
7
|
+
@inner_procedure = inner_procedure
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.build_wrapper(callback_type,
|
11
|
-
if
|
12
|
-
new(callback_type,
|
10
|
+
def self.build_wrapper(callback_type, inner_procedure)
|
11
|
+
if inner_procedure.kind_of? ::Proc
|
12
|
+
new(callback_type, inner_procedure).wrapper
|
13
13
|
else
|
14
|
-
|
14
|
+
inner_procedure
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -23,13 +23,16 @@ module Workflow
|
|
23
23
|
keyrest_string,
|
24
24
|
procedure_string].compact.join(', ')
|
25
25
|
|
26
|
-
|
26
|
+
inner_procedure = self.inner_procedure
|
27
27
|
str = <<-EOF
|
28
28
|
Proc.new do |target#{', callbacks' if around_callback?}|
|
29
29
|
attributes = transition_context.attributes.dup
|
30
|
+
event_args = transition_context.event_args.dup
|
31
|
+
name_arg = -> (name) { attributes.delete(name) || event_args.shift }
|
30
32
|
target.instance_exec(#{arguments})
|
31
33
|
end
|
32
34
|
EOF
|
35
|
+
# puts str
|
33
36
|
eval(str)
|
34
37
|
end
|
35
38
|
|
@@ -44,7 +47,7 @@ module Workflow
|
|
44
47
|
names = []
|
45
48
|
names << 'target' if params.shift
|
46
49
|
(names << 'callbacks') && params.shift if around_callback?
|
47
|
-
names += params.map{|
|
50
|
+
names += params.map{|name| "name_arg.call(:#{name})"}
|
48
51
|
return names.join(', ') if names.any?
|
49
52
|
end
|
50
53
|
|
@@ -60,11 +63,11 @@ module Workflow
|
|
60
63
|
end
|
61
64
|
|
62
65
|
def rest_param_string
|
63
|
-
'*
|
66
|
+
'*event_args' if rest_param
|
64
67
|
end
|
65
68
|
|
66
69
|
def procedure_string
|
67
|
-
'&
|
70
|
+
'&inner_procedure'
|
68
71
|
end
|
69
72
|
|
70
73
|
def name_params
|
@@ -90,10 +93,10 @@ module Workflow
|
|
90
93
|
end
|
91
94
|
|
92
95
|
def parameters
|
93
|
-
|
96
|
+
inner_procedure.parameters
|
94
97
|
end
|
95
98
|
def arity
|
96
|
-
|
99
|
+
inner_procedure.arity
|
97
100
|
end
|
98
101
|
end
|
99
102
|
end
|
data/lib/workflow/version.rb
CHANGED