business_flow 0.2.0 → 0.3.0

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: 59f3aeae56b561faae00b90ca42cda1eb822124b
4
- data.tar.gz: 937c3212f40c0dcfa708e94b846f225f9d46e161
3
+ metadata.gz: d9c94efd239befaaff61cf57d19cb6b275435d02
4
+ data.tar.gz: 944f1a4075af4781ea1ee873366c4900e5e26241
5
5
  SHA512:
6
- metadata.gz: 6ae409cc67496b6e54c228c7f93cb93cbf6efe837878c15a5be5dce789036e9bcdbf5e38ded9b178016026a73d3ccc30b9e402f71097353d97c3e649a73b4add
7
- data.tar.gz: d31ee7ddf43d7d5ac03f0d1d51e3d64d3893a38de3939e434dfe3d340f7a2449fba0b317258b22b059c2251a750299f038fbebafbfbeedf34b18501a37d3d154
6
+ metadata.gz: 2fc9b094b2677ed5e13ed1b17c58d07de5340bef3608540f6171783656d238a54346988361dd96bf94665b9730941edffd247d06c9fd9695355cb6822df9e01a
7
+ data.tar.gz: a3a9e27a570b2e14669521de739982abb05558723c7b820a22c1d60ccbbd76b6e4a5e8fb589cf08e6f224b5ce04d9d5322b2f1fa1d10cc9689c410b58cf4fd5c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.1.2)
4
+ business_flow (0.3.0)
5
5
  activemodel (>= 3.0)
6
6
 
7
7
  GEM
@@ -8,88 +8,97 @@ module BusinessFlow
8
8
  # Check output slots even if they're not going through our defined setter
9
9
  # Conditional steps?
10
10
  # ActiveSupport notifiers
11
- class Base
12
- include ActiveModel::Validations
13
- include DSL
11
+ module Base
12
+ def self.included(klass)
13
+ klass.include(DSL)
14
+ klass.prepend(InstanceMethods)
15
+ end
14
16
 
15
- attr_reader :parameter_object
16
- private :parameter_object
17
+ module InstanceMethods
18
+ attr_reader :parameter_object
19
+ private :parameter_object
17
20
 
18
- def initialize(parameter_object)
19
- @parameter_object = parameter_object
20
- end
21
+ def initialize(parameter_object)
22
+ @parameter_object = parameter_object
23
+ super()
24
+ end
21
25
 
22
- def call
23
- return if invalid?
24
- process_steps
25
- end
26
+ def call
27
+ return if invalid?
28
+ if defined?(super)
29
+ super
30
+ else
31
+ process_steps
32
+ end
33
+ end
26
34
 
27
- private
35
+ private
28
36
 
29
- def process_steps
30
- steps.each do |step_name|
31
- catch(:halt_step) do
32
- process_step(step_name)
37
+ def process_steps
38
+ steps.each do |step_name|
39
+ catch(:halt_step) do
40
+ process_step(step_name)
41
+ end
42
+ break if errors.any?
33
43
  end
34
- break if errors.any?
35
44
  end
36
- end
37
45
 
38
- def process_step(step)
39
- input_object = marshall_input_object(step.inputs)
40
- result = step.dispatch(self, input_object)
41
- marshall_outputs(result, step.outputs) if result.present?
42
- end
46
+ def process_step(step)
47
+ input_object = marshall_input_object(step.inputs)
48
+ result = step.dispatch(self, input_object)
49
+ marshall_outputs(result, step.outputs) if result.present?
50
+ end
43
51
 
44
- def marshall_input_object(input_object)
45
- return self if input_object.blank?
46
- Hash[input_object.map do |input_name, input_value|
47
- [
48
- input_name,
49
- process_input(input_value)
50
- ]
51
- end
52
- ]
53
- end
52
+ def marshall_input_object(input_object)
53
+ return self if input_object.blank?
54
+ Hash[input_object.map do |input_name, input_value|
55
+ [
56
+ input_name,
57
+ process_input(input_value)
58
+ ]
59
+ end
60
+ ]
61
+ end
54
62
 
55
- def marshall_outputs(result, output_object)
56
- merge_other_errors(result.errors, result.class.name.underscore)
57
- output_object.each do |(output_name, output_setter)|
58
- break if errors.any?
59
- output = result.public_send(output_name)
60
- process_output(output, output_setter)
63
+ def marshall_outputs(result, output_object)
64
+ merge_other_errors(result.errors, result.class.name.underscore)
65
+ output_object.each do |(output_name, output_setter)|
66
+ break if errors.any?
67
+ output = result.public_send(output_name)
68
+ process_output(output, output_setter)
69
+ end
61
70
  end
62
- end
63
71
 
64
- def merge_other_errors(other_errors, base_name)
65
- other_errors.each do |attribute, message|
66
- attribute = "#{base_name}.#{attribute}"
67
- (errors[attribute] << message).uniq!
72
+ def merge_other_errors(other_errors, base_name)
73
+ other_errors.each do |attribute, message|
74
+ attribute = "#{base_name}.#{attribute}"
75
+ (errors[attribute] << message).uniq!
76
+ end
68
77
  end
69
- end
70
78
 
71
- def process_input(input_value)
72
- case input_value
73
- when Symbol
74
- send(input_value)
75
- when Proc
76
- instance_exec(&input_value)
77
- else
78
- input_value
79
+ def process_input(input_value)
80
+ case input_value
81
+ when Symbol
82
+ send(input_value)
83
+ when Proc
84
+ instance_exec(&input_value)
85
+ else
86
+ input_value
87
+ end
79
88
  end
80
- end
81
89
 
82
- def process_output(output, output_setter)
83
- case output_setter
84
- when Symbol
85
- send("#{output_setter}=", output)
86
- when Proc
87
- instance_exec(output, &output_setter)
90
+ def process_output(output, output_setter)
91
+ case output_setter
92
+ when Symbol
93
+ send("#{output_setter}=", output)
94
+ when Proc
95
+ instance_exec(output, &output_setter)
96
+ end
88
97
  end
89
- end
90
98
 
91
- def steps
92
- self.class.step_queue || []
99
+ def steps
100
+ self.class.step_queue || []
101
+ end
93
102
  end
94
103
  end
95
104
  end
@@ -1,3 +1,3 @@
1
1
  module BusinessFlow
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
data/lib/business_flow.rb CHANGED
@@ -6,5 +6,5 @@ require 'business_flow/step'
6
6
  require 'business_flow/dsl'
7
7
  require 'business_flow/base'
8
8
 
9
- module BusienssFlow
9
+ module BusinessFlow
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Scarborough