flow 0.10.9 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flow/flow_base.rb +1 -1
- data/lib/flow/operation/accessors.rb +23 -25
- data/lib/flow/operation/core.rb +1 -1
- data/lib/flow/operation_base.rb +1 -1
- data/lib/flow/spec_helper.rb +1 -1
- data/lib/flow/state_base.rb +1 -7
- data/lib/flow/version.rb +1 -1
- data/lib/flow.rb +1 -5
- metadata +12 -14
- data/lib/flow/state/output.rb +0 -59
- data/lib/flow/state/status.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b58b685f68376d3cbb4e00e869d9f1a16d15ffb74fe13ed9c8088c89b5b915ca
|
4
|
+
data.tar.gz: 0a9028c03e0c7196f4feb4a2744f00262d3b2799e8752a87e95484a0344d47ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9749b0bbbcb7a59ff426c81d0a1e5c05a913a383752afc641d8c90679b24f9a572873ad8efc9e7abaac8f19664f1b5e5e8b7474a71ab88f63abe04fcd1ba5bfa
|
7
|
+
data.tar.gz: ef93d1bd2d6e73f417daebb0c6884fb323677a9ff322eb7be8577506ce75c5b0596a161a56e716b18f049dc3c0625488f90995b00218ce2c648f9d91a10f73e1
|
data/lib/flow/flow_base.rb
CHANGED
@@ -10,7 +10,7 @@ require_relative "flow/trigger"
|
|
10
10
|
|
11
11
|
# A **Flow** is a collection of procedurally executed **Operations** sharing a common **State**.
|
12
12
|
module Flow
|
13
|
-
class FlowBase < RootObject
|
13
|
+
class FlowBase < Substance::RootObject
|
14
14
|
include Conjunction::Junction
|
15
15
|
suffixed_with "Flow"
|
16
16
|
|
@@ -1,58 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "set"
|
4
|
+
|
3
5
|
module Flow
|
4
6
|
module Operation
|
5
7
|
module Accessors
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
10
|
included do
|
9
|
-
class_attribute :_state_readers, instance_writer: false, default:
|
10
|
-
class_attribute :_state_writers, instance_writer: false, default:
|
11
|
-
class_attribute :_state_accessors, instance_writer: false, default:
|
11
|
+
class_attribute :_state_readers, instance_writer: false, default: Set.new
|
12
|
+
class_attribute :_state_writers, instance_writer: false, default: Set.new
|
13
|
+
class_attribute :_state_accessors, instance_writer: false, default: Set.new
|
12
14
|
end
|
13
15
|
|
14
|
-
|
16
|
+
module ClassMethods
|
15
17
|
protected
|
16
18
|
|
17
|
-
def state_reader(
|
18
|
-
|
19
|
+
def state_reader(*names, prefix: false)
|
20
|
+
names.each do |name|
|
21
|
+
delegate name, prefix: prefix, to: :state
|
19
22
|
|
20
|
-
|
23
|
+
_add_state_reader_tracker(name.to_sym)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
|
-
def state_writer(
|
24
|
-
|
27
|
+
def state_writer(*names, prefix: false)
|
28
|
+
names.each do |name|
|
29
|
+
delegate "#{name}=", prefix: prefix, to: :state
|
25
30
|
|
26
|
-
|
31
|
+
_add_state_writer_tracker(name.to_sym)
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
|
-
def state_accessor(
|
30
|
-
|
31
|
-
|
35
|
+
def state_accessor(*names, prefix: false)
|
36
|
+
names.each do |name|
|
37
|
+
state_reader name, prefix: prefix
|
38
|
+
state_writer name, prefix: prefix
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
private
|
35
43
|
|
36
44
|
def _add_state_reader_tracker(name)
|
37
|
-
|
38
|
-
|
39
|
-
_add_state_accessor_tracker(name) if _state_writers.include?(name)
|
45
|
+
_state_accessors << name if _state_writers.include?(name)
|
40
46
|
_state_readers << name
|
41
47
|
end
|
42
48
|
|
43
49
|
def _add_state_writer_tracker(name)
|
44
|
-
|
45
|
-
|
46
|
-
_add_state_accessor_tracker(name) if _state_readers.include?(name)
|
50
|
+
_state_accessors << name if _state_readers.include?(name)
|
47
51
|
_state_writers << name
|
48
52
|
end
|
49
53
|
|
50
|
-
def _add_state_accessor_tracker(name)
|
51
|
-
return if _state_accessors.include?(name)
|
52
|
-
|
53
|
-
_state_accessors << name
|
54
|
-
end
|
55
|
-
|
56
54
|
def inherited(base)
|
57
55
|
base._state_readers = _state_readers.dup
|
58
56
|
base._state_writers = _state_writers.dup
|
data/lib/flow/operation/core.rb
CHANGED
@@ -15,7 +15,7 @@ module Flow
|
|
15
15
|
class_methods do
|
16
16
|
def state_proxy_class
|
17
17
|
@state_proxy_class ||= Class.new(StateProxy).tap do |proxy_class|
|
18
|
-
delegate_method_names = _state_writers.map { |method_name| "#{method_name}=" } + _state_readers
|
18
|
+
delegate_method_names = _state_writers.map { |method_name| "#{method_name}=" } + _state_readers.to_a
|
19
19
|
proxy_class.delegate(*delegate_method_names, to: :_state) if delegate_method_names.any?
|
20
20
|
end
|
21
21
|
end
|
data/lib/flow/operation_base.rb
CHANGED
@@ -11,7 +11,7 @@ require_relative "operation/transactions"
|
|
11
11
|
|
12
12
|
# An **Operation** is a service object which is executed with a **State**.
|
13
13
|
module Flow
|
14
|
-
class OperationBase < RootObject
|
14
|
+
class OperationBase < Substance::RootObject
|
15
15
|
include TransactionWrapper
|
16
16
|
include Operation::Accessors
|
17
17
|
include Operation::Callbacks
|
data/lib/flow/spec_helper.rb
CHANGED
data/lib/flow/state_base.rb
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "state/status"
|
4
|
-
require_relative "state/output"
|
5
|
-
|
6
3
|
# A **State** is an aggregation of input and derived data.
|
7
4
|
module Flow
|
8
|
-
class StateBase <
|
5
|
+
class StateBase < Substance::OutputObject
|
9
6
|
include Conjunction::Junction
|
10
7
|
suffixed_with "State"
|
11
|
-
|
12
|
-
include State::Status
|
13
|
-
include State::Output
|
14
8
|
end
|
15
9
|
end
|
data/lib/flow/version.rb
CHANGED
data/lib/flow.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
require "active_model"
|
4
4
|
require "active_support"
|
5
5
|
|
6
|
-
require "spicerack"
|
7
6
|
require "conjunction"
|
8
7
|
require "malfunction"
|
8
|
+
require "substance"
|
9
9
|
|
10
10
|
require_relative "flow/version"
|
11
11
|
|
@@ -15,10 +15,6 @@ require_relative "flow/concerns/transaction_wrapper"
|
|
15
15
|
|
16
16
|
require_relative "flow/malfunction/base"
|
17
17
|
|
18
|
-
# TODO: Remove inheritance nonsense, just use Substance once deprecation is removed from Spicerack
|
19
|
-
class Flow::RootObject < (defined?(Substance::RootObject) ? Substance::RootObject : Spicerack::RootObject); end
|
20
|
-
class Flow::InputModel < (defined?(Substance::InputModel) ? Substance::InputModel : Spicerack::InputModel); end
|
21
|
-
|
22
18
|
require_relative "flow/flow_base"
|
23
19
|
require_relative "flow/operation_base"
|
24
20
|
require_relative "flow/state_base"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2021-
|
15
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activemodel
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: 5.2.1
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
46
|
+
name: conjunction
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '1.0'
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
66
|
+
name: short_circu_it
|
67
67
|
requirement: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
@@ -83,12 +83,12 @@ dependencies:
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '1.0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: substance
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.
|
91
|
+
version: 0.26.0
|
92
92
|
- - "<"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '1.0'
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0.
|
101
|
+
version: 0.26.0
|
102
102
|
- - "<"
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '1.0'
|
@@ -244,16 +244,16 @@ dependencies:
|
|
244
244
|
name: shoulda-matchers
|
245
245
|
requirement: !ruby/object:Gem::Requirement
|
246
246
|
requirements:
|
247
|
-
- -
|
247
|
+
- - "~>"
|
248
248
|
- !ruby/object:Gem::Version
|
249
|
-
version: 4.0
|
249
|
+
version: '4.0'
|
250
250
|
type: :development
|
251
251
|
prerelease: false
|
252
252
|
version_requirements: !ruby/object:Gem::Requirement
|
253
253
|
requirements:
|
254
|
-
- -
|
254
|
+
- - "~>"
|
255
255
|
- !ruby/object:Gem::Version
|
256
|
-
version: 4.0
|
256
|
+
version: '4.0'
|
257
257
|
- !ruby/object:Gem::Dependency
|
258
258
|
name: rspice
|
259
259
|
requirement: !ruby/object:Gem::Requirement
|
@@ -340,8 +340,6 @@ files:
|
|
340
340
|
- lib/flow/rspec/shared_contexts/with_failing_operation.rb
|
341
341
|
- lib/flow/rspec/shoulda_matcher_helper.rb
|
342
342
|
- lib/flow/spec_helper.rb
|
343
|
-
- lib/flow/state/output.rb
|
344
|
-
- lib/flow/state/status.rb
|
345
343
|
- lib/flow/state_base.rb
|
346
344
|
- lib/flow/state_proxy.rb
|
347
345
|
- lib/flow/version.rb
|
@@ -402,7 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
402
400
|
- !ruby/object:Gem::Version
|
403
401
|
version: '0'
|
404
402
|
requirements: []
|
405
|
-
rubygems_version: 3.2.
|
403
|
+
rubygems_version: 3.2.25
|
406
404
|
signing_key:
|
407
405
|
specification_version: 4
|
408
406
|
summary: Write modular and reusable business logic that's understandable and maintainable.
|
data/lib/flow/state/output.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Output data is created by Operations during runtime and CANNOT be validated or provided as part of the input.
|
4
|
-
module Flow
|
5
|
-
module State
|
6
|
-
module Output
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
class_attribute :_outputs, instance_writer: false, default: []
|
11
|
-
|
12
|
-
delegate :_outputs, to: :class
|
13
|
-
|
14
|
-
after_validation do
|
15
|
-
next unless validated?
|
16
|
-
|
17
|
-
_outputs.each do |key|
|
18
|
-
public_send("#{key}=".to_sym, _defaults[key].value) if _defaults.key?(key) && public_send(key).nil?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class_methods do
|
24
|
-
def inherited(base)
|
25
|
-
base._outputs = _outputs.dup
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def output(output, default: nil, &block)
|
32
|
-
_outputs << output
|
33
|
-
define_attribute output
|
34
|
-
define_default output, static: default, &block
|
35
|
-
ensure_validation_before output
|
36
|
-
ensure_validation_before "#{output}=".to_sym
|
37
|
-
end
|
38
|
-
|
39
|
-
def ensure_validation_before(method)
|
40
|
-
around_method method do |*arguments|
|
41
|
-
raise NotValidatedError unless validated?
|
42
|
-
|
43
|
-
super(*arguments)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def outputs
|
49
|
-
return {} if _outputs.empty?
|
50
|
-
|
51
|
-
output_struct.new(*_outputs.map(&method(:public_send)))
|
52
|
-
end
|
53
|
-
|
54
|
-
def output_struct
|
55
|
-
Struct.new(*_outputs)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/lib/flow/state/status.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# The State status is used to ensure and enforce internal consistency.
|
4
|
-
module Flow
|
5
|
-
module State
|
6
|
-
module Status
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
after_validation { self.was_validated = errors.empty? }
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
attr_accessor :was_validated
|
15
|
-
end
|
16
|
-
|
17
|
-
def validated?
|
18
|
-
was_validated.present?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|