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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8270a626780c254a58897c2cef2e0b162b5fbcae
4
- data.tar.gz: 1a9e4480f3306fc8b10136d2dce4c92d3570b529
3
+ metadata.gz: ebaf58ab065f71da4435f23776e611a91a3db506
4
+ data.tar.gz: 7c2852bd1e597559436ab141a3a66c8840425589
5
5
  SHA512:
6
- metadata.gz: 70c376c21353280fbff28bac40ba2509581c681e2591788793d1031bf40923f21665c2e5285609e899e65a3b74acb4390d511cd14108beeb8b438ab861e82085
7
- data.tar.gz: b79da68fd8e266ff0d1a55623a60db87c1499dfeb0ccfc0e551dd4ee77186b4ee57b5e5f8f26fdc6665db07c8caf0fac71419926b3b0fef9b1bcc42f37e5de1b
6
+ metadata.gz: dd9d5cdca15811c52c65974a329e810bf8712a3caa16e159a9661393126ff0fecf18c052294d4896b40e0f555de7429acc2217595a21a6f61801ecfbbfbfa0bd
7
+ data.tar.gz: adb0500c94fef7a0b0f8d7b01bb724dd7d6feb5161c3ee254e38d6e3e5ad5cafa7bcc7eac33ec5725f76e291d9a24366c516af7a9df823b6098a98f4e4157374
data/bin/console CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "workflow"
5
-
6
5
  # You can add fixtures and/or initialization code here to make experimenting
7
6
  # with your gem easier. You can also use a different console, if you like.
8
7
 
@@ -1,17 +1,17 @@
1
1
  module Workflow
2
2
  module Callbacks
3
3
  class TransitionCallbackWrapper
4
- attr_reader :callback_type, :raw_proc
5
- def initialize(callback_type, raw_proc)
4
+ attr_reader :callback_type, :inner_procedure
5
+ def initialize(callback_type, inner_procedure)
6
6
  @callback_type = callback_type
7
- @raw_proc = raw_proc
7
+ @inner_procedure = inner_procedure
8
8
  end
9
9
 
10
- def self.build_wrapper(callback_type, raw_proc)
11
- if raw_proc.kind_of? ::Proc
12
- new(callback_type, raw_proc).wrapper
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
- raw_proc
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
- raw_proc = self.raw_proc
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{|t| "transition_context.#{t}"}
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
- '*transition_context.event_args' if rest_param
66
+ '*event_args' if rest_param
64
67
  end
65
68
 
66
69
  def procedure_string
67
- '&raw_proc'
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
- raw_proc.parameters
96
+ inner_procedure.parameters
94
97
  end
95
98
  def arity
96
- raw_proc.arity
99
+ inner_procedure.arity
97
100
  end
98
101
  end
99
102
  end
@@ -43,6 +43,10 @@ module Workflow
43
43
  [from, to, event, event_args]
44
44
  end
45
45
 
46
+ def respond_to?(method)
47
+ named_arguments.key?(method) || super
48
+ end
49
+
46
50
  def method_missing(method, *args)
47
51
  if named_arguments.key?(method)
48
52
  named_arguments[method]
@@ -1,3 +1,3 @@
1
1
  module Workflow
2
- VERSION = "1.4.1.3"
2
+ VERSION = "1.4.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1.3
4
+ version: 1.4.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Gannon