bcdd-result 0.12.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -2
- data/CHANGELOG.md +99 -16
- data/README.md +618 -247
- data/Rakefile +1 -1
- data/Steepfile +4 -4
- data/examples/multiple_listeners/Rakefile +55 -0
- data/examples/multiple_listeners/app/models/account/member.rb +10 -0
- data/examples/multiple_listeners/app/models/account/owner_creation.rb +62 -0
- data/examples/multiple_listeners/app/models/account.rb +11 -0
- data/examples/multiple_listeners/app/models/user/creation.rb +67 -0
- data/examples/multiple_listeners/app/models/user/token/creation.rb +51 -0
- data/examples/multiple_listeners/app/models/user/token.rb +7 -0
- data/examples/multiple_listeners/app/models/user.rb +15 -0
- data/examples/multiple_listeners/config/boot.rb +16 -0
- data/examples/multiple_listeners/config/initializers/bcdd.rb +9 -0
- data/examples/multiple_listeners/config.rb +27 -0
- data/examples/multiple_listeners/db/setup.rb +60 -0
- data/examples/multiple_listeners/lib/bcdd/result/event_logs_record.rb +27 -0
- data/examples/multiple_listeners/lib/bcdd/result/rollback_on_failure.rb +15 -0
- data/examples/multiple_listeners/lib/event_logs_listener/stdout.rb +60 -0
- data/examples/multiple_listeners/lib/runtime_breaker.rb +11 -0
- data/examples/service_objects/Rakefile +36 -0
- data/examples/service_objects/app/models/account/member.rb +10 -0
- data/examples/service_objects/app/models/account.rb +11 -0
- data/examples/service_objects/app/models/user/token.rb +7 -0
- data/examples/service_objects/app/models/user.rb +15 -0
- data/examples/service_objects/app/services/account/owner_creation.rb +47 -0
- data/examples/service_objects/app/services/application_service.rb +79 -0
- data/examples/service_objects/app/services/user/creation.rb +56 -0
- data/examples/service_objects/app/services/user/token/creation.rb +37 -0
- data/examples/service_objects/config/boot.rb +17 -0
- data/examples/service_objects/config/initializers/bcdd.rb +9 -0
- data/examples/service_objects/config.rb +20 -0
- data/examples/service_objects/db/setup.rb +49 -0
- data/examples/single_listener/Rakefile +92 -0
- data/examples/single_listener/app/models/account/member.rb +10 -0
- data/examples/single_listener/app/models/account/owner_creation.rb +62 -0
- data/examples/single_listener/app/models/account.rb +11 -0
- data/examples/single_listener/app/models/user/creation.rb +67 -0
- data/examples/single_listener/app/models/user/token/creation.rb +51 -0
- data/examples/single_listener/app/models/user/token.rb +7 -0
- data/examples/single_listener/app/models/user.rb +15 -0
- data/examples/single_listener/config/boot.rb +16 -0
- data/examples/single_listener/config/initializers/bcdd.rb +9 -0
- data/examples/single_listener/config.rb +23 -0
- data/examples/single_listener/db/setup.rb +49 -0
- data/examples/single_listener/lib/bcdd/result/rollback_on_failure.rb +15 -0
- data/examples/single_listener/lib/runtime_breaker.rb +11 -0
- data/examples/single_listener/lib/single_event_logs_listener.rb +117 -0
- data/lib/bcdd/{result/context → context}/callable_and_then.rb +5 -4
- data/lib/bcdd/{result/context → context}/expectations/mixin.rb +3 -3
- data/lib/bcdd/{result/context → context}/expectations.rb +2 -2
- data/lib/bcdd/context/failure.rb +9 -0
- data/lib/bcdd/{result/context → context}/mixin.rb +4 -4
- data/lib/bcdd/context/success.rb +37 -0
- data/lib/bcdd/context.rb +91 -0
- data/lib/bcdd/failure.rb +23 -0
- data/lib/bcdd/result/_self.rb +198 -0
- data/lib/bcdd/result/callable_and_then/caller.rb +1 -1
- data/lib/bcdd/result/config/switchers/addons.rb +2 -2
- data/lib/bcdd/result/config/switchers/constant_aliases.rb +1 -3
- data/lib/bcdd/result/config/switchers/features.rb +5 -5
- data/lib/bcdd/result/config/switchers/pattern_matching.rb +1 -1
- data/lib/bcdd/result/config.rb +9 -2
- data/lib/bcdd/result/contract/for_types.rb +1 -1
- data/lib/bcdd/result/contract/for_types_and_values.rb +2 -0
- data/lib/bcdd/result/contract/type_checker.rb +4 -0
- data/lib/bcdd/result/event_logs/config.rb +28 -0
- data/lib/bcdd/result/event_logs/listener.rb +51 -0
- data/lib/bcdd/result/event_logs/listeners.rb +87 -0
- data/lib/bcdd/result/event_logs/tracking/disabled.rb +15 -0
- data/lib/bcdd/result/event_logs/tracking/enabled.rb +161 -0
- data/lib/bcdd/result/event_logs/tracking.rb +26 -0
- data/lib/bcdd/result/{transitions → event_logs}/tree.rb +46 -4
- data/lib/bcdd/result/event_logs.rb +27 -0
- data/lib/bcdd/result/expectations/mixin.rb +2 -2
- data/lib/bcdd/result/failure.rb +1 -3
- data/lib/bcdd/result/ignored_types.rb +14 -0
- data/lib/bcdd/result/mixin.rb +2 -2
- data/lib/bcdd/result/success.rb +1 -3
- data/lib/bcdd/result/version.rb +1 -1
- data/lib/bcdd/result.rb +25 -191
- data/lib/bcdd/success.rb +23 -0
- data/sig/bcdd/context.rbs +175 -0
- data/sig/bcdd/failure.rbs +13 -0
- data/sig/bcdd/result/config.rbs +1 -2
- data/sig/bcdd/result/context.rbs +2 -165
- data/sig/bcdd/result/contract.rbs +1 -0
- data/sig/bcdd/result/event_logs.rbs +189 -0
- data/sig/bcdd/result/ignored_types.rbs +9 -0
- data/sig/bcdd/result.rbs +14 -32
- data/sig/bcdd/success.rbs +13 -0
- metadata +75 -22
- data/lib/bcdd/result/context/failure.rb +0 -9
- data/lib/bcdd/result/context/success.rb +0 -19
- data/lib/bcdd/result/context.rb +0 -93
- data/lib/bcdd/result/failure/methods.rb +0 -21
- data/lib/bcdd/result/success/methods.rb +0 -21
- data/lib/bcdd/result/transitions/tracking/disabled.rb +0 -27
- data/lib/bcdd/result/transitions/tracking/enabled.rb +0 -100
- data/lib/bcdd/result/transitions/tracking.rb +0 -20
- data/lib/bcdd/result/transitions.rb +0 -28
- data/sig/bcdd/result/transitions.rbs +0 -100
data/lib/bcdd/result.rb
CHANGED
@@ -1,195 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
8
|
-
|
9
|
-
|
10
|
-
require_relative 'result/
|
11
|
-
require_relative 'result/
|
12
|
-
require_relative 'result/
|
13
|
-
require_relative 'result/
|
14
|
-
require_relative 'result/
|
15
|
-
require_relative 'result/
|
16
|
-
require_relative 'result/
|
17
|
-
require_relative 'result/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
def self.config
|
29
|
-
Config.instance
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.configuration
|
33
|
-
yield(config)
|
34
|
-
|
35
|
-
config.freeze
|
36
|
-
end
|
37
|
-
|
38
|
-
def initialize(type:, value:, source: nil, expectations: nil, terminal: nil)
|
39
|
-
data = Data.new(kind, type, value)
|
40
|
-
|
41
|
-
@type_checker = Contract.evaluate(data, expectations)
|
42
|
-
@source = source
|
43
|
-
@terminal = terminal || kind == :failure
|
44
|
-
@data = data
|
45
|
-
|
46
|
-
self.unknown = true
|
47
|
-
self.transitions = Transitions::Tracking::EMPTY
|
48
|
-
|
49
|
-
Transitions.tracking.record(self)
|
50
|
-
end
|
51
|
-
|
52
|
-
def terminal?
|
53
|
-
terminal
|
54
|
-
end
|
55
|
-
|
56
|
-
def type
|
57
|
-
data.type
|
58
|
-
end
|
59
|
-
|
60
|
-
def value
|
61
|
-
data.value
|
62
|
-
end
|
63
|
-
|
64
|
-
def success?(_type = nil)
|
65
|
-
raise Error::NotImplemented
|
66
|
-
end
|
67
|
-
|
68
|
-
def failure?(_type = nil)
|
69
|
-
raise Error::NotImplemented
|
70
|
-
end
|
71
|
-
|
72
|
-
def value_or(&_block)
|
73
|
-
raise Error::NotImplemented
|
74
|
-
end
|
75
|
-
|
76
|
-
def on(*types, &block)
|
77
|
-
raise Error::MissingTypeArgument if types.empty?
|
78
|
-
|
79
|
-
tap { known(block) if type_checker.allow?(types) }
|
80
|
-
end
|
81
|
-
|
82
|
-
def on_success(*types, &block)
|
83
|
-
tap { known(block) if type_checker.allow_success?(types) && success? }
|
84
|
-
end
|
85
|
-
|
86
|
-
def on_failure(*types, &block)
|
87
|
-
tap { known(block) if type_checker.allow_failure?(types) && failure? }
|
88
|
-
end
|
89
|
-
|
90
|
-
def on_unknown
|
91
|
-
tap { yield(value, type) if unknown }
|
92
|
-
end
|
93
|
-
|
94
|
-
def and_then(method_name = nil, injected_value = nil, &block)
|
95
|
-
return self if terminal?
|
96
|
-
|
97
|
-
method_name && block and raise ::ArgumentError, 'method_name and block are mutually exclusive'
|
98
|
-
|
99
|
-
method_name ? call_and_then_source_method(method_name, injected_value) : call_and_then_block(block)
|
100
|
-
end
|
101
|
-
|
102
|
-
def and_then!(source, injected_value = nil, _call: nil)
|
103
|
-
raise Error::CallableAndThenDisabled unless Config.instance.feature.enabled?(:and_then!)
|
104
|
-
|
105
|
-
return self if terminal?
|
106
|
-
|
107
|
-
call_and_then_callable!(source, value: value, injected_value: injected_value, method_name: _call)
|
108
|
-
end
|
109
|
-
|
110
|
-
def handle
|
111
|
-
handler = Handler.new(self, type_checker: type_checker)
|
112
|
-
|
113
|
-
yield handler
|
114
|
-
|
115
|
-
handler.send(:outcome)
|
116
|
-
end
|
117
|
-
|
118
|
-
def ==(other)
|
119
|
-
self.class == other.class && type == other.type && value == other.value
|
120
|
-
end
|
121
|
-
|
122
|
-
def hash
|
123
|
-
[self.class, type, value].hash
|
124
|
-
end
|
125
|
-
|
126
|
-
def inspect
|
127
|
-
format('#<%<class_name>s type=%<type>p value=%<value>p>', class_name: self.class.name, type: type, value: value)
|
128
|
-
end
|
129
|
-
|
130
|
-
def deconstruct
|
131
|
-
[type, value]
|
132
|
-
end
|
133
|
-
|
134
|
-
def deconstruct_keys(_keys)
|
135
|
-
{ kind => { type => value } }
|
136
|
-
end
|
137
|
-
|
138
|
-
alias eql? ==
|
139
|
-
alias on_type on
|
140
|
-
|
141
|
-
private
|
142
|
-
|
143
|
-
def kind
|
144
|
-
:unknown
|
145
|
-
end
|
146
|
-
|
147
|
-
def known(block)
|
148
|
-
self.unknown = false
|
149
|
-
|
150
|
-
block.call(value, type)
|
151
|
-
end
|
152
|
-
|
153
|
-
def call_and_then_source_method(method_name, injected_value)
|
154
|
-
method = source.method(method_name)
|
155
|
-
|
156
|
-
Transitions.tracking.record_and_then(method, injected_value, source) do
|
157
|
-
result = call_and_then_source_method!(method, injected_value)
|
158
|
-
|
159
|
-
ensure_result_object(result, origin: :method)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def call_and_then_source_method!(method, injected_value)
|
164
|
-
case method.arity
|
165
|
-
when 0 then source.send(method.name)
|
166
|
-
when 1 then source.send(method.name, value)
|
167
|
-
when 2 then source.send(method.name, value, injected_value)
|
168
|
-
else raise Error::InvalidSourceMethodArity.build(source: source, method: method, max_arity: 2)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def call_and_then_block(block)
|
173
|
-
Transitions.tracking.record_and_then(:block, nil, source) do
|
174
|
-
result = call_and_then_block!(block)
|
175
|
-
|
176
|
-
ensure_result_object(result, origin: :block)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def call_and_then_block!(block)
|
181
|
-
block.call(value)
|
182
|
-
end
|
183
|
-
|
184
|
-
def call_and_then_callable!(source, value:, injected_value:, method_name:)
|
185
|
-
CallableAndThen::Caller.call(source, value: value, injected_value: injected_value, method_name: method_name)
|
186
|
-
end
|
187
|
-
|
188
|
-
def ensure_result_object(result, origin:)
|
189
|
-
raise Error::UnexpectedOutcome.build(outcome: result, origin: origin) unless result.is_a?(::BCDD::Result)
|
190
|
-
|
191
|
-
return result if result.source.equal?(source)
|
192
|
-
|
193
|
-
raise Error::InvalidResultSource.build(given_result: result, expected_source: source)
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module BCDD
|
6
|
+
require_relative 'success'
|
7
|
+
require_relative 'failure'
|
8
|
+
|
9
|
+
class Result
|
10
|
+
require_relative 'result/version'
|
11
|
+
require_relative 'result/error'
|
12
|
+
require_relative 'result/ignored_types'
|
13
|
+
require_relative 'result/event_logs'
|
14
|
+
require_relative 'result/callable_and_then'
|
15
|
+
require_relative 'result/data'
|
16
|
+
require_relative 'result/handler'
|
17
|
+
require_relative 'result/failure'
|
18
|
+
require_relative 'result/success'
|
19
|
+
require_relative 'result/mixin'
|
20
|
+
require_relative 'result/contract'
|
21
|
+
require_relative 'result/expectations'
|
22
|
+
require_relative 'result/config'
|
23
|
+
require_relative 'result/_self'
|
24
|
+
|
25
|
+
require_relative 'context'
|
26
|
+
|
27
|
+
Context = ::BCDD::Context
|
194
28
|
end
|
195
29
|
end
|
data/lib/bcdd/success.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BCDD
|
4
|
+
module Success
|
5
|
+
def success?(type = nil)
|
6
|
+
type.nil? || type_checker.allow_success?([type])
|
7
|
+
end
|
8
|
+
|
9
|
+
def failure?(_type = nil)
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def value_or
|
14
|
+
value
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def kind
|
20
|
+
:success
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
class BCDD::Context < BCDD::Result
|
2
|
+
EXPECTED_OUTCOME: String
|
3
|
+
|
4
|
+
SourceMethodArity: ^(Method) -> Integer
|
5
|
+
|
6
|
+
attr_reader acc: Hash[Symbol, untyped]
|
7
|
+
|
8
|
+
def initialize: (
|
9
|
+
type: Symbol,
|
10
|
+
value: untyped,
|
11
|
+
?source: untyped,
|
12
|
+
?expectations: BCDD::Result::Contract::Evaluator,
|
13
|
+
?terminal: bool
|
14
|
+
) -> void
|
15
|
+
|
16
|
+
def and_then: (?Symbol, **untyped) ?{ (Hash[Symbol, untyped]) -> untyped } -> untyped
|
17
|
+
|
18
|
+
def and_then!: (untyped, **untyped) -> untyped
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def call_and_then_source_method: (Symbol, Hash[Symbol, untyped]) -> BCDD::Context
|
23
|
+
|
24
|
+
def call_and_then_callable!: (untyped, value: untyped, injected_value: untyped, method_name: (Symbol | nil)) -> BCDD::Context
|
25
|
+
|
26
|
+
def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Context
|
27
|
+
|
28
|
+
def raise_unexpected_outcome_error: (BCDD::Context | untyped, Symbol) -> void
|
29
|
+
end
|
30
|
+
|
31
|
+
class BCDD::Context
|
32
|
+
class Error < BCDD::Result::Error
|
33
|
+
class InvalidExposure < BCDD::Context::Error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class BCDD::Context
|
39
|
+
class Success < BCDD::Context
|
40
|
+
include BCDD::Success
|
41
|
+
|
42
|
+
FetchValues: Proc
|
43
|
+
|
44
|
+
def and_expose: (Symbol, Array[Symbol], terminal: bool) -> BCDD::Context::Success
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.Success: (Symbol, **untyped) -> BCDD::Context::Success
|
48
|
+
end
|
49
|
+
|
50
|
+
module BCDD::Context::CallableAndThen
|
51
|
+
class Caller < BCDD::Result::CallableAndThen::Caller
|
52
|
+
module KeyArgs
|
53
|
+
def self.parameters?: (untyped) -> bool
|
54
|
+
|
55
|
+
def self.invalid_arity: (untyped, Symbol) -> BCDD::Result::CallableAndThen::Error::InvalidArity
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.call: (
|
59
|
+
untyped source,
|
60
|
+
value: untyped,
|
61
|
+
injected_value: untyped,
|
62
|
+
method_name: (Symbol | nil),
|
63
|
+
) -> BCDD::Context
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def self.call_proc!: (
|
68
|
+
untyped source,
|
69
|
+
Hash[Symbol, untyped] value,
|
70
|
+
nil injected_value
|
71
|
+
) -> BCDD::Context
|
72
|
+
|
73
|
+
def self.call_method!: (
|
74
|
+
untyped source,
|
75
|
+
Method method,
|
76
|
+
Hash[Symbol, untyped] value,
|
77
|
+
nil injected_value
|
78
|
+
) -> BCDD::Context
|
79
|
+
|
80
|
+
def self.callable_method: (
|
81
|
+
untyped source,
|
82
|
+
(Symbol | nil) method_name
|
83
|
+
) -> ::Method
|
84
|
+
|
85
|
+
def self.ensure_result_object: (
|
86
|
+
untyped source,
|
87
|
+
untyped value,
|
88
|
+
BCDD::Context result
|
89
|
+
) -> BCDD::Context
|
90
|
+
|
91
|
+
def self.expected_result_object: () -> singleton(BCDD::Context)
|
92
|
+
|
93
|
+
def self.expected_outcome: () -> String
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class BCDD::Context
|
98
|
+
class Failure < BCDD::Context
|
99
|
+
include BCDD::Failure
|
100
|
+
|
101
|
+
def and_expose: (Symbol, Array[Symbol], **untyped) -> BCDD::Context::Failure
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.Failure: (Symbol, **untyped) -> BCDD::Context::Failure
|
105
|
+
end
|
106
|
+
|
107
|
+
class BCDD::Context
|
108
|
+
module Mixin
|
109
|
+
Factory: singleton(BCDD::Result::Mixin::Factory)
|
110
|
+
|
111
|
+
module Methods
|
112
|
+
def Success: (Symbol, **untyped) -> BCDD::Context::Success
|
113
|
+
|
114
|
+
def Failure: (Symbol, **untyped) -> BCDD::Context::Failure
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def _ResultAs: (singleton(BCDD::Context), Symbol, untyped, ?terminal: bool) -> untyped
|
119
|
+
end
|
120
|
+
|
121
|
+
module Addons
|
122
|
+
module Continue
|
123
|
+
include BCDD::Context::Mixin::Methods
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
def Continue: (**untyped) -> BCDD::Context::Success
|
128
|
+
end
|
129
|
+
|
130
|
+
module Given
|
131
|
+
include BCDD::Context::Mixin::Methods
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def Given: (*untyped) -> BCDD::Context::Success
|
136
|
+
end
|
137
|
+
|
138
|
+
OPTIONS: Hash[Symbol, Module]
|
139
|
+
|
140
|
+
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.mixin_module: -> singleton(BCDD::Context::Mixin)
|
145
|
+
|
146
|
+
def self.result_factory: -> singleton(BCDD::Context)
|
147
|
+
end
|
148
|
+
|
149
|
+
class BCDD::Context::Expectations < BCDD::Result::Expectations
|
150
|
+
def self.mixin_module: -> singleton(BCDD::Context::Expectations::Mixin)
|
151
|
+
|
152
|
+
def self.result_factory_without_expectations: -> singleton(BCDD::Result)
|
153
|
+
|
154
|
+
def Success: (Symbol, **untyped) -> BCDD::Context::Success
|
155
|
+
def Failure: (Symbol, **untyped) -> BCDD::Context::Failure
|
156
|
+
end
|
157
|
+
|
158
|
+
module BCDD::Context::Expectations::Mixin
|
159
|
+
Methods: singleton(BCDD::Result::Expectations::Mixin::Methods)
|
160
|
+
Factory: singleton(BCDD::Result::Expectations::Mixin::Factory)
|
161
|
+
|
162
|
+
module Addons
|
163
|
+
module Continue
|
164
|
+
private def Continue: (**untyped) -> BCDD::Context::Success
|
165
|
+
end
|
166
|
+
|
167
|
+
module Given
|
168
|
+
private def Given: (*untyped) -> BCDD::Context::Success
|
169
|
+
end
|
170
|
+
|
171
|
+
OPTIONS: Hash[Symbol, Module]
|
172
|
+
|
173
|
+
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module BCDD
|
2
|
+
module Failure
|
3
|
+
def success?: (?Symbol type) -> bool
|
4
|
+
def failure?: (?Symbol type) -> bool
|
5
|
+
def value_or: { (untyped) -> untyped } -> untyped
|
6
|
+
def value: -> untyped
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def kind: -> Symbol
|
11
|
+
def type_checker: -> BCDD::Result::Contract::TypeChecker
|
12
|
+
end
|
13
|
+
end
|
data/sig/bcdd/result/config.rbs
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
class BCDD::Result::Config
|
2
|
-
include Singleton
|
3
|
-
|
4
2
|
ADDON: Hash[Symbol, Hash[Symbol, untyped]]
|
5
3
|
FEATURE: Hash[Symbol, Hash[Symbol, untyped]]
|
6
4
|
PATTERN_MATCHING: Hash[Symbol, Hash[Symbol, untyped]]
|
@@ -15,6 +13,7 @@ class BCDD::Result::Config
|
|
15
13
|
def initialize: -> void
|
16
14
|
|
17
15
|
def and_then!: () -> BCDD::Result::CallableAndThen::Config
|
16
|
+
def event_logs: () -> BCDD::Result::EventLogs::Config
|
18
17
|
|
19
18
|
def freeze: -> BCDD::Result::Config
|
20
19
|
def options: -> Hash[Symbol, BCDD::Result::Config::Switcher]
|
data/sig/bcdd/result/context.rbs
CHANGED
@@ -1,166 +1,3 @@
|
|
1
|
-
class BCDD::Result
|
2
|
-
|
3
|
-
|
4
|
-
SourceMethodArity: ^(Method) -> Integer
|
5
|
-
|
6
|
-
attr_reader acc: Hash[Symbol, untyped]
|
7
|
-
|
8
|
-
def initialize: (
|
9
|
-
type: Symbol,
|
10
|
-
value: untyped,
|
11
|
-
?source: untyped,
|
12
|
-
?expectations: BCDD::Result::Contract::Evaluator,
|
13
|
-
?terminal: bool
|
14
|
-
) -> void
|
15
|
-
|
16
|
-
def and_then: (?Symbol, **untyped) ?{ (Hash[Symbol, untyped]) -> untyped } -> untyped
|
17
|
-
|
18
|
-
def and_then!: (untyped, **untyped) -> untyped
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def call_and_then_source_method: (Symbol, Hash[Symbol, untyped]) -> BCDD::Result::Context
|
23
|
-
|
24
|
-
def call_and_then_callable!: (untyped, value: untyped, injected_value: untyped, method_name: (Symbol | nil)) -> BCDD::Result::Context
|
25
|
-
|
26
|
-
def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Result::Context
|
27
|
-
|
28
|
-
def raise_unexpected_outcome_error: (BCDD::Result::Context | untyped, Symbol) -> void
|
29
|
-
end
|
30
|
-
|
31
|
-
class BCDD::Result::Context
|
32
|
-
class Success < BCDD::Result::Context
|
33
|
-
include BCDD::Result::Success::Methods
|
34
|
-
|
35
|
-
def and_expose: (Symbol, Array[Symbol], terminal: bool) -> BCDD::Result::Context::Success
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
|
39
|
-
end
|
40
|
-
|
41
|
-
module BCDD::Result::Context::CallableAndThen
|
42
|
-
class Caller < BCDD::Result::CallableAndThen::Caller
|
43
|
-
module KeyArgs
|
44
|
-
def self.parameters?: (untyped) -> bool
|
45
|
-
|
46
|
-
def self.invalid_arity: (untyped, Symbol) -> BCDD::Result::CallableAndThen::Error::InvalidArity
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.call: (
|
50
|
-
untyped source,
|
51
|
-
value: untyped,
|
52
|
-
injected_value: untyped,
|
53
|
-
method_name: (Symbol | nil),
|
54
|
-
) -> BCDD::Result::Context
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def self.call_proc!: (
|
59
|
-
untyped source,
|
60
|
-
Hash[Symbol, untyped] value,
|
61
|
-
nil injected_value
|
62
|
-
) -> BCDD::Result::Context
|
63
|
-
|
64
|
-
def self.call_method!: (
|
65
|
-
untyped source,
|
66
|
-
Method method,
|
67
|
-
Hash[Symbol, untyped] value,
|
68
|
-
nil injected_value
|
69
|
-
) -> BCDD::Result::Context
|
70
|
-
|
71
|
-
def self.callable_method: (
|
72
|
-
untyped source,
|
73
|
-
(Symbol | nil) method_name
|
74
|
-
) -> ::Method
|
75
|
-
|
76
|
-
def self.ensure_result_object: (
|
77
|
-
untyped source,
|
78
|
-
untyped value,
|
79
|
-
BCDD::Result::Context result
|
80
|
-
) -> BCDD::Result::Context
|
81
|
-
|
82
|
-
def self.expected_result_object: () -> singleton(BCDD::Result::Context)
|
83
|
-
|
84
|
-
def self.expected_outcome: () -> String
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
class BCDD::Result::Context
|
89
|
-
class Failure < BCDD::Result::Context
|
90
|
-
include BCDD::Result::Failure::Methods
|
91
|
-
|
92
|
-
def and_expose: (Symbol, Array[Symbol], **untyped) -> BCDD::Result::Context::Failure
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
|
96
|
-
end
|
97
|
-
|
98
|
-
class BCDD::Result::Context
|
99
|
-
module Mixin
|
100
|
-
Factory: singleton(BCDD::Result::Mixin::Factory)
|
101
|
-
|
102
|
-
module Methods
|
103
|
-
def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
|
104
|
-
|
105
|
-
def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def _ResultAs: (singleton(BCDD::Result::Context), Symbol, untyped, ?terminal: bool) -> untyped
|
110
|
-
end
|
111
|
-
|
112
|
-
module Addons
|
113
|
-
module Continue
|
114
|
-
include BCDD::Result::Context::Mixin::Methods
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
def Continue: (**untyped) -> BCDD::Result::Context::Success
|
119
|
-
end
|
120
|
-
|
121
|
-
module Given
|
122
|
-
include BCDD::Result::Context::Mixin::Methods
|
123
|
-
|
124
|
-
private
|
125
|
-
|
126
|
-
def Given: (*untyped) -> BCDD::Result::Context::Success
|
127
|
-
end
|
128
|
-
|
129
|
-
OPTIONS: Hash[Symbol, Module]
|
130
|
-
|
131
|
-
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def self.mixin_module: -> singleton(BCDD::Result::Context::Mixin)
|
136
|
-
|
137
|
-
def self.result_factory: -> singleton(BCDD::Result::Context)
|
138
|
-
end
|
139
|
-
|
140
|
-
class BCDD::Result::Context::Expectations < BCDD::Result::Expectations
|
141
|
-
def self.mixin_module: -> singleton(BCDD::Result::Context::Expectations::Mixin)
|
142
|
-
|
143
|
-
def self.result_factory_without_expectations: -> singleton(BCDD::Result)
|
144
|
-
|
145
|
-
def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
|
146
|
-
def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
|
147
|
-
end
|
148
|
-
|
149
|
-
module BCDD::Result::Context::Expectations::Mixin
|
150
|
-
Methods: singleton(BCDD::Result::Expectations::Mixin::Methods)
|
151
|
-
Factory: singleton(BCDD::Result::Expectations::Mixin::Factory)
|
152
|
-
|
153
|
-
module Addons
|
154
|
-
module Continue
|
155
|
-
private def Continue: (**untyped) -> BCDD::Result::Context::Success
|
156
|
-
end
|
157
|
-
|
158
|
-
module Given
|
159
|
-
private def Given: (*untyped) -> BCDD::Result::Context::Success
|
160
|
-
end
|
161
|
-
|
162
|
-
OPTIONS: Hash[Symbol, Module]
|
163
|
-
|
164
|
-
def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
|
165
|
-
end
|
1
|
+
class BCDD::Result
|
2
|
+
Context: BCDD::Context
|
166
3
|
end
|
@@ -26,6 +26,7 @@ module BCDD::Result::Contract
|
|
26
26
|
expectations: BCDD::Result::Contract::Evaluator
|
27
27
|
) -> void
|
28
28
|
|
29
|
+
def allow!: (Symbol) -> Symbol
|
29
30
|
def allow?: (Array[Symbol]) -> bool
|
30
31
|
def allow_success?: (Array[Symbol]) -> bool
|
31
32
|
def allow_failure?: (Array[Symbol]) -> bool
|