business_flow 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2320f053af0c28e31b77f23e3147eeccbd8c1268
4
- data.tar.gz: a02bf9a70b9e3360419cdcc9541f314811607766
3
+ metadata.gz: a606f274a7654da5d5ea5bcecec5ad78e6694a94
4
+ data.tar.gz: 16864e345d6f8b536dd7ae20631b4782511e349f
5
5
  SHA512:
6
- metadata.gz: e036addb535580b05fe087e30bf8714ef8bf915ba6a4ec2fbf7ad5e9a79e6a4e00d7abc473f93407b9480c6a7e2cd160fa802e857f61f50297eb1687b4f2444e
7
- data.tar.gz: 5733ad83bb8b44e8939d8ff8ab3f49b1c33c2612ef6db622f6356289df0f68b7fb7eefbdb2fffb792f74a49bff1c403404cc811fc614baba1b2386c9b72a38b9
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.2)
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.3)
39
+ parser (2.5.0.4)
40
40
  ast (~> 2.4.0)
41
41
  powerpack (0.1.1)
42
42
  rainbow (3.0.0)
@@ -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
- ActiveSupport::Notifications.instrument(flow_name, flow: @flow) do
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
- "business_flow.flow.#{@flow.class.to_s.underscore}"
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.#{@flow.class.to_s.underscore}." \
46
- "#{step.to_s.underscore}"
54
+ "business_flow.step.#{step_event_name(step)}"
47
55
  end
48
56
  end
49
57
  end
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module BusinessFlow
2
- VERSION = '0.4.2'.freeze
2
+ VERSION = '0.4.3'.freeze
3
3
  end
data/lib/business_flow.rb CHANGED
@@ -8,5 +8,6 @@ require 'business_flow/default_step_executor'
8
8
  require 'business_flow/dsl'
9
9
  require 'business_flow/base'
10
10
 
11
+ # Makes the magic happen.
11
12
  module BusinessFlow
12
13
  end
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.2
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-14 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel