business_flow 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/business_flow/base.rb +4 -0
- data/lib/business_flow/default_step_executor.rb +12 -4
- data/lib/business_flow/step.rb +6 -2
- data/lib/business_flow/version.rb +1 -1
- data/lib/business_flow.rb +1 -0
- 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: a606f274a7654da5d5ea5bcecec5ad78e6694a94
|
4
|
+
data.tar.gz: 16864e345d6f8b536dd7ae20631b4782511e349f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 067107876f8431cec4f40545b53ef44706127b64854ba8f130b8d65c1e378971c43ca3f642dc054acca7f80cfef205154b2e4cc82ad2424e7a399d3b8034a65f
|
7
|
+
data.tar.gz: 73ead3612688678e0490910751edc18f6a535e2e6fe8155c7222c4465771b4860631d166984f25f6ba6f99bcb18ed169cda0288980b13479e79e021fced3dd9f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
business_flow (0.4.
|
4
|
+
business_flow (0.4.3)
|
5
5
|
activemodel (>= 3.0)
|
6
6
|
activesupport (>= 3.0)
|
7
7
|
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
json (2.1.0)
|
37
37
|
minitest (5.11.3)
|
38
38
|
parallel (1.12.1)
|
39
|
-
parser (2.5.0.
|
39
|
+
parser (2.5.0.4)
|
40
40
|
ast (~> 2.4.0)
|
41
41
|
powerpack (0.1.1)
|
42
42
|
rainbow (3.0.0)
|
data/lib/business_flow/base.rb
CHANGED
@@ -4,6 +4,7 @@ module BusinessFlow
|
|
4
4
|
# call! to raise errors
|
5
5
|
# Hooks for cross cutting concerns
|
6
6
|
# Figure out how much we can freeze
|
7
|
+
# :reek:ModuleInitialize
|
7
8
|
module Base
|
8
9
|
def self.included(klass)
|
9
10
|
klass.include(DSL)
|
@@ -16,6 +17,9 @@ module BusinessFlow
|
|
16
17
|
attr_reader :parameter_object
|
17
18
|
private :parameter_object
|
18
19
|
|
20
|
+
# Initialize is here so that we can set the parameter object, and then
|
21
|
+
# allow our "parent" class to handle any additional initialization that
|
22
|
+
# it needs to do.
|
19
23
|
def initialize(parameter_object)
|
20
24
|
@parameter_object = parameter_object
|
21
25
|
catch(:halt_step) do
|
@@ -9,7 +9,8 @@ module BusinessFlow
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
12
|
-
|
12
|
+
return if @flow.errors.present?
|
13
|
+
ActiveSupport::Notifications.instrument(flow_event_name, flow: @flow) do
|
13
14
|
@step_queue.each do |step|
|
14
15
|
break unless process_step(step)
|
15
16
|
end
|
@@ -38,12 +39,19 @@ module BusinessFlow
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def flow_name
|
41
|
-
|
42
|
+
@flow_name ||= @flow.class.to_s.underscore
|
43
|
+
end
|
44
|
+
|
45
|
+
def flow_event_name
|
46
|
+
@flow_event_name ||= "business_flow.flow.#{flow_name}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def step_event_name(step)
|
50
|
+
"#{flow_name}.#{step.to_s.underscore}"
|
42
51
|
end
|
43
52
|
|
44
53
|
def event_name(step)
|
45
|
-
"business_flow.step.#{
|
46
|
-
"#{step.to_s.underscore}"
|
54
|
+
"business_flow.step.#{step_event_name(step)}"
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
data/lib/business_flow/step.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module BusinessFlow
|
2
|
+
# Step is a conditional callable which can marshal its own inputs, and
|
3
|
+
# returns a value which can marshal errors and outputs into a given object.
|
2
4
|
class Step
|
5
|
+
# Represents inputs needed to execute a step.
|
3
6
|
class Inputs
|
4
7
|
attr_reader :inputs
|
5
8
|
|
@@ -29,6 +32,8 @@ module BusinessFlow
|
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
35
|
+
# Represents the result of a step, and allows setting response values on
|
36
|
+
# an object, and merging error data into the same object.
|
32
37
|
class Result
|
33
38
|
def initialize(result, output_map)
|
34
39
|
@result = result
|
@@ -67,7 +72,7 @@ module BusinessFlow
|
|
67
72
|
def merge_errors_into(errors)
|
68
73
|
return if @result_errors.blank?
|
69
74
|
@result_errors.each do |attribute, message|
|
70
|
-
attribute = "#{@result.class.name}.#{attribute}"
|
75
|
+
attribute = "#{@result.class.name.underscore}.#{attribute}"
|
71
76
|
(errors[attribute] << message).uniq!
|
72
77
|
end
|
73
78
|
throw :halt_step
|
@@ -103,7 +108,6 @@ module BusinessFlow
|
|
103
108
|
@condition = opts[:condition] || proc { true }
|
104
109
|
end
|
105
110
|
|
106
|
-
# @klass can be a symbol or class
|
107
111
|
def call(parameter_source)
|
108
112
|
parameters = @input_object.parameters_from_source(parameter_source)
|
109
113
|
if @condition.call(parameter_source, parameters)
|
data/lib/business_flow.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Scarborough
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|