business_flow 0.19.5 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +95 -0
- data/.reek.yml +5 -0
- data/.rubocop.yml +9 -6
- data/.ruby-version +1 -1
- data/Appraisals +48 -0
- data/Gemfile +10 -3
- data/Gemfile.lock +115 -62
- data/README.md +15 -1
- data/bin/setup +6 -0
- data/business_flow.gemspec +3 -3
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/activemodel_4.2.gemfile +24 -0
- data/gemfiles/activemodel_4.2.gemfile.lock +131 -0
- data/gemfiles/activemodel_5.2.gemfile +24 -0
- data/gemfiles/activemodel_5.2.gemfile.lock +169 -0
- data/gemfiles/activemodel_6.1.gemfile +23 -0
- data/gemfiles/activemodel_6.1.gemfile.lock +174 -0
- data/gemfiles/activemodel_7.0.gemfile +21 -0
- data/gemfiles/activemodel_7.0.gemfile.lock +162 -0
- data/gemfiles/activemodel_7.1.gemfile +21 -0
- data/gemfiles/activemodel_7.1.gemfile.lock +176 -0
- data/gemfiles/activemodel_7.2.gemfile +21 -0
- data/gemfiles/activemodel_7.2.gemfile.lock +174 -0
- data/gemfiles/activemodel_8.0.gemfile +21 -0
- data/gemfiles/activemodel_8.0.gemfile.lock +176 -0
- data/lib/business_flow/cacheable.rb +1 -1
- data/lib/business_flow/callable.rb +1 -1
- data/lib/business_flow/cluster_lock.rb +3 -3
- data/lib/business_flow/dsl.rb +29 -27
- data/lib/business_flow/instrument.rb +16 -1
- data/lib/business_flow/instrumented_executor.rb +3 -12
- data/lib/business_flow/instrumented_step_executor.rb +8 -1
- data/lib/business_flow/step.rb +3 -3
- data/lib/business_flow/version.rb +1 -1
- data/lib/business_flow.rb +1 -0
- metadata +25 -12
data/lib/business_flow/dsl.rb
CHANGED
@@ -65,10 +65,10 @@ module BusinessFlow
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# Allows a field to be retrieved from the initialiaztion parameters
|
68
|
-
def wants(field, default = nil, opts = {}, &
|
68
|
+
def wants(field, default = nil, opts = {}, &)
|
69
69
|
internal_name = :"wants_#{field}"
|
70
70
|
default = proc {} unless default || block_given?
|
71
|
-
uses(internal_name, default, opts, &
|
71
|
+
uses(internal_name, default, opts, &)
|
72
72
|
inputs.add_wants(ParameterField.new(field, internal_name))
|
73
73
|
end
|
74
74
|
|
@@ -238,7 +238,7 @@ module BusinessFlow
|
|
238
238
|
key
|
239
239
|
end
|
240
240
|
|
241
|
-
# Provides the
|
241
|
+
# Provides the minimum necessary instance methods to support the use of
|
242
242
|
# ActiveMode::Errors, outside of what's provided by ActiveModel::Naming
|
243
243
|
module InstanceMethods
|
244
244
|
def read_attribute_for_validation(key)
|
@@ -270,11 +270,33 @@ module BusinessFlow
|
|
270
270
|
klass.step_executor.new(klass.step_queue, self).call
|
271
271
|
end
|
272
272
|
|
273
|
+
def errors
|
274
|
+
@errors ||= ActiveModel::Errors.new(self)
|
275
|
+
end
|
276
|
+
|
277
|
+
def errors?
|
278
|
+
# We're explicitly using the instance variable here so that if no
|
279
|
+
# errors have been created, we don't initialize the error object.
|
280
|
+
@errors&.present?
|
281
|
+
end
|
282
|
+
|
283
|
+
def valid?(_context = nil)
|
284
|
+
# We're explicitly using the instance variable here so that if no
|
285
|
+
# errors have been created, we don't initialize the error object.
|
286
|
+
@errors.blank?
|
287
|
+
end
|
288
|
+
|
289
|
+
def invalid?(context = nil)
|
290
|
+
!valid?(context)
|
291
|
+
end
|
292
|
+
|
293
|
+
private
|
294
|
+
|
273
295
|
# Responsible for setting the parameter object and validating inputs.
|
274
296
|
# This is a method directly on the object instead of something we
|
275
297
|
# handle through instance_eval/exec for performance reasons.
|
276
298
|
# :reek:NilCheck This is where we ensure that our needs are non-nil.
|
277
|
-
|
299
|
+
def _business_flow_dsl_initialize(parameter_object, needs)
|
278
300
|
@parameter_object = parameter_object
|
279
301
|
needs.each do |need|
|
280
302
|
if send(need).nil?
|
@@ -286,7 +308,7 @@ module BusinessFlow
|
|
286
308
|
end
|
287
309
|
|
288
310
|
# :reek:NilCheck
|
289
|
-
|
311
|
+
def _business_flow_parameter_fetch(key)
|
290
312
|
value = _business_flow_parameter_inner_fetch(key)
|
291
313
|
# We only want to fall back to a default if we were
|
292
314
|
# given nil. Other falsy vlues should be directly used.
|
@@ -295,7 +317,7 @@ module BusinessFlow
|
|
295
317
|
value
|
296
318
|
end
|
297
319
|
|
298
|
-
|
320
|
+
def _business_flow_parameter_inner_fetch(key)
|
299
321
|
if @parameter_object.is_a?(Hash) && @parameter_object.key?(key)
|
300
322
|
@parameter_object[key]
|
301
323
|
else
|
@@ -305,31 +327,11 @@ module BusinessFlow
|
|
305
327
|
nil
|
306
328
|
end
|
307
329
|
|
308
|
-
|
330
|
+
def _business_flow_dsl_parameters
|
309
331
|
@_business_flow_dsl_parameters ||=
|
310
332
|
self.class.inputs.all.to_h { |input| [input, _business_flow_parameter_inner_fetch(input)] }
|
311
333
|
end
|
312
334
|
|
313
|
-
def errors
|
314
|
-
@errors ||= ActiveModel::Errors.new(self)
|
315
|
-
end
|
316
|
-
|
317
|
-
def errors?
|
318
|
-
# We're explicitly using the instance variable here so that if no
|
319
|
-
# errors have been created, we don't initialize the error object.
|
320
|
-
@errors&.present?
|
321
|
-
end
|
322
|
-
|
323
|
-
def valid?(_context = nil)
|
324
|
-
# We're explicitly using the instance variable here so that if no
|
325
|
-
# errors have been created, we don't initialize the error object.
|
326
|
-
@errors.blank?
|
327
|
-
end
|
328
|
-
|
329
|
-
def invalid?(context = nil)
|
330
|
-
!valid?(context)
|
331
|
-
end
|
332
|
-
|
333
335
|
# Responsible for creating fields on one or more classes and noting the of
|
334
336
|
# field
|
335
337
|
class FieldList
|
@@ -13,8 +13,23 @@ module BusinessFlow
|
|
13
13
|
module ClassMethods
|
14
14
|
INSTRUMENTATION_PREFIX = 'business_flow'
|
15
15
|
|
16
|
+
def with_instrument_payload(payload = nil, opts = {}, &blk)
|
17
|
+
if payload.is_a?(Hash)
|
18
|
+
@payload = Step.new(Callable.new(proc { payload }), {})
|
19
|
+
elsif payload || blk
|
20
|
+
@payload = Step.new(Callable.new(payload || blk),
|
21
|
+
{ default_output: :instrument_payload }.merge(opts))
|
22
|
+
else
|
23
|
+
@payload ||= Step.new(Callable.new(proc { {} }), opts)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.instrument_payload(flow)
|
28
|
+
catch(:halt_step) { flow.class.with_instrument_payload.call(flow)&.merge_into(flow) }
|
29
|
+
end
|
30
|
+
|
16
31
|
def instrument(name, flow)
|
17
|
-
payload = { flow: flow }
|
32
|
+
payload = { flow: flow }.merge(ClassMethods.instrument_payload(flow))
|
18
33
|
ActiveSupport::Notifications.instrument(
|
19
34
|
"#{INSTRUMENTATION_PREFIX}.#{name}.#{instrumentation_name}", payload
|
20
35
|
) do
|
@@ -4,12 +4,11 @@ module BusinessFlow
|
|
4
4
|
# Fire ActiveSupport events for every step that's run and on errors
|
5
5
|
class InstrumentedExecutor < DefaultStepExecutor
|
6
6
|
def call
|
7
|
-
|
8
|
-
|
9
|
-
ActiveSupport::Notifications.instrument(name, payload) do
|
7
|
+
f_class = flow.class
|
8
|
+
f_class.instrument('flow', flow) do |payload|
|
10
9
|
super
|
10
|
+
notify_errors(f_class.event_name, payload)
|
11
11
|
end
|
12
|
-
notify_errors(name, payload)
|
13
12
|
end
|
14
13
|
|
15
14
|
protected
|
@@ -19,13 +18,5 @@ module BusinessFlow
|
|
19
18
|
|
20
19
|
ActiveSupport::Notifications.publish("#{name}.error", payload)
|
21
20
|
end
|
22
|
-
|
23
|
-
def flow_name
|
24
|
-
@flow_name ||= flow.class.instrumentation_name
|
25
|
-
end
|
26
|
-
|
27
|
-
def flow_event_name
|
28
|
-
@flow_event_name ||= flow.class.event_name
|
29
|
-
end
|
30
21
|
end
|
31
22
|
end
|
@@ -7,7 +7,10 @@ module BusinessFlow
|
|
7
7
|
|
8
8
|
def execute_step(step)
|
9
9
|
i_name = event_name(step)
|
10
|
-
i_payload = { flow: flow,
|
10
|
+
i_payload = { flow: flow,
|
11
|
+
step: step }.merge(
|
12
|
+
::BusinessFlow::Instrument::ClassMethods.instrument_payload(flow)
|
13
|
+
)
|
11
14
|
ActiveSupport::Notifications.instrument(i_name, i_payload) do |payload|
|
12
15
|
payload[:step_result] = super
|
13
16
|
end
|
@@ -21,5 +24,9 @@ module BusinessFlow
|
|
21
24
|
def event_name(step)
|
22
25
|
"business_flow.step.#{step_event_name(step)}"
|
23
26
|
end
|
27
|
+
|
28
|
+
def flow_name
|
29
|
+
@flow_name ||= flow.class.instrumentation_name
|
30
|
+
end
|
24
31
|
end
|
25
32
|
end
|
data/lib/business_flow/step.rb
CHANGED
@@ -229,8 +229,6 @@ module BusinessFlow
|
|
229
229
|
@callable.to_s
|
230
230
|
end
|
231
231
|
|
232
|
-
private
|
233
|
-
|
234
232
|
PARAMETERS_NO_INPUT = 'parameter_source'
|
235
233
|
PARAMETERS_WITH_INPUT =
|
236
234
|
'@input_object.parameters_from_source(parameter_source)'
|
@@ -244,7 +242,9 @@ module BusinessFlow
|
|
244
242
|
else
|
245
243
|
CONDITION_FAILED
|
246
244
|
end
|
247
|
-
)
|
245
|
+
).freeze
|
246
|
+
|
247
|
+
private
|
248
248
|
|
249
249
|
def update_call_method
|
250
250
|
params = @input_object ? PARAMETERS_WITH_INPUT : PARAMETERS_NO_INPUT
|
data/lib/business_flow.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Scarborough
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activemodel
|
@@ -19,7 +18,7 @@ dependencies:
|
|
19
18
|
version: '4.2'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '8'
|
21
|
+
version: '8.1'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +28,7 @@ dependencies:
|
|
29
28
|
version: '4.2'
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '8'
|
31
|
+
version: '8.1'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: activesupport
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +38,7 @@ dependencies:
|
|
39
38
|
version: '4.2'
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '8'
|
41
|
+
version: '8.1'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,14 +48,14 @@ dependencies:
|
|
49
48
|
version: '4.2'
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '8'
|
53
|
-
description:
|
51
|
+
version: '8.1'
|
54
52
|
email:
|
55
53
|
- alex@teak.io
|
56
54
|
executables: []
|
57
55
|
extensions: []
|
58
56
|
extra_rdoc_files: []
|
59
57
|
files:
|
58
|
+
- ".circleci/config.yml"
|
60
59
|
- ".gitignore"
|
61
60
|
- ".reek.yml"
|
62
61
|
- ".rspec"
|
@@ -64,6 +63,7 @@ files:
|
|
64
63
|
- ".ruby-gemset"
|
65
64
|
- ".ruby-version"
|
66
65
|
- ".travis.yml"
|
66
|
+
- Appraisals
|
67
67
|
- Gemfile
|
68
68
|
- Gemfile.lock
|
69
69
|
- LICENSE.txt
|
@@ -72,6 +72,21 @@ files:
|
|
72
72
|
- bin/console
|
73
73
|
- bin/setup
|
74
74
|
- business_flow.gemspec
|
75
|
+
- gemfiles/.bundle/config
|
76
|
+
- gemfiles/activemodel_4.2.gemfile
|
77
|
+
- gemfiles/activemodel_4.2.gemfile.lock
|
78
|
+
- gemfiles/activemodel_5.2.gemfile
|
79
|
+
- gemfiles/activemodel_5.2.gemfile.lock
|
80
|
+
- gemfiles/activemodel_6.1.gemfile
|
81
|
+
- gemfiles/activemodel_6.1.gemfile.lock
|
82
|
+
- gemfiles/activemodel_7.0.gemfile
|
83
|
+
- gemfiles/activemodel_7.0.gemfile.lock
|
84
|
+
- gemfiles/activemodel_7.1.gemfile
|
85
|
+
- gemfiles/activemodel_7.1.gemfile.lock
|
86
|
+
- gemfiles/activemodel_7.2.gemfile
|
87
|
+
- gemfiles/activemodel_7.2.gemfile.lock
|
88
|
+
- gemfiles/activemodel_8.0.gemfile
|
89
|
+
- gemfiles/activemodel_8.0.gemfile.lock
|
75
90
|
- lib/business_flow.rb
|
76
91
|
- lib/business_flow/base.rb
|
77
92
|
- lib/business_flow/cacheable.rb
|
@@ -93,7 +108,6 @@ licenses:
|
|
93
108
|
- MIT
|
94
109
|
metadata:
|
95
110
|
rubygems_mfa_required: 'true'
|
96
|
-
post_install_message:
|
97
111
|
rdoc_options: []
|
98
112
|
require_paths:
|
99
113
|
- lib
|
@@ -101,15 +115,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
115
|
requirements:
|
102
116
|
- - ">="
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
118
|
+
version: 3.1.0
|
105
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
120
|
requirements:
|
107
121
|
- - ">="
|
108
122
|
- !ruby/object:Gem::Version
|
109
123
|
version: '0'
|
110
124
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
-
signing_key:
|
125
|
+
rubygems_version: 3.6.9
|
113
126
|
specification_version: 4
|
114
127
|
summary: General purpose management of service object flows
|
115
128
|
test_files: []
|