bcdd-result 0.13.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -4
  3. data/CHANGELOG.md +46 -17
  4. data/README.md +381 -220
  5. data/Rakefile +1 -1
  6. data/Steepfile +1 -1
  7. data/examples/multiple_listeners/Rakefile +8 -8
  8. data/examples/multiple_listeners/app/models/account/owner_creation.rb +1 -1
  9. data/examples/multiple_listeners/app/models/user/creation.rb +1 -1
  10. data/examples/multiple_listeners/app/models/user/token/creation.rb +1 -1
  11. data/examples/multiple_listeners/config/initializers/bcdd.rb +0 -2
  12. data/examples/multiple_listeners/config.rb +3 -3
  13. data/examples/multiple_listeners/db/setup.rb +2 -3
  14. data/examples/multiple_listeners/lib/bcdd/result/event_logs_record.rb +27 -0
  15. data/examples/multiple_listeners/lib/event_logs_listener/stdout.rb +60 -0
  16. data/examples/multiple_listeners/lib/runtime_breaker.rb +1 -1
  17. data/examples/service_objects/Rakefile +36 -0
  18. data/examples/service_objects/app/models/account/member.rb +10 -0
  19. data/examples/service_objects/app/models/account.rb +11 -0
  20. data/examples/service_objects/app/models/user/token.rb +7 -0
  21. data/examples/service_objects/app/models/user.rb +15 -0
  22. data/examples/service_objects/app/services/account/owner_creation.rb +47 -0
  23. data/examples/service_objects/app/services/application_service.rb +79 -0
  24. data/examples/service_objects/app/services/user/creation.rb +56 -0
  25. data/examples/service_objects/app/services/user/token/creation.rb +37 -0
  26. data/examples/service_objects/config/boot.rb +17 -0
  27. data/examples/service_objects/config/initializers/bcdd.rb +9 -0
  28. data/examples/service_objects/config.rb +20 -0
  29. data/examples/service_objects/db/setup.rb +49 -0
  30. data/examples/single_listener/Rakefile +5 -5
  31. data/examples/single_listener/app/models/account/owner_creation.rb +1 -1
  32. data/examples/single_listener/app/models/user/creation.rb +1 -1
  33. data/examples/single_listener/app/models/user/token/creation.rb +1 -1
  34. data/examples/single_listener/config/initializers/bcdd.rb +0 -2
  35. data/examples/single_listener/config.rb +1 -1
  36. data/examples/single_listener/lib/{single_transitions_listener.rb → single_event_logs_listener.rb} +32 -23
  37. data/lib/bcdd/{result/context → context}/callable_and_then.rb +5 -4
  38. data/lib/bcdd/{result/context → context}/expectations/mixin.rb +1 -1
  39. data/lib/bcdd/{result/context → context}/expectations.rb +2 -2
  40. data/lib/bcdd/context/failure.rb +9 -0
  41. data/lib/bcdd/{result/context → context}/mixin.rb +2 -2
  42. data/lib/bcdd/{result/context → context}/success.rb +6 -6
  43. data/lib/bcdd/context.rb +91 -0
  44. data/lib/bcdd/failure.rb +23 -0
  45. data/lib/bcdd/result/_self.rb +198 -0
  46. data/lib/bcdd/result/callable_and_then/caller.rb +1 -1
  47. data/lib/bcdd/result/config/switchers/addons.rb +2 -2
  48. data/lib/bcdd/result/config/switchers/constant_aliases.rb +1 -3
  49. data/lib/bcdd/result/config/switchers/features.rb +5 -5
  50. data/lib/bcdd/result/config/switchers/pattern_matching.rb +1 -1
  51. data/lib/bcdd/result/config.rb +7 -5
  52. data/lib/bcdd/result/contract/type_checker.rb +4 -0
  53. data/lib/bcdd/result/{transitions → event_logs}/config.rb +5 -3
  54. data/lib/bcdd/result/{transitions → event_logs}/listener.rb +5 -5
  55. data/lib/bcdd/result/{transitions → event_logs}/listeners.rb +17 -17
  56. data/lib/bcdd/result/{transitions → event_logs}/tracking/disabled.rb +1 -1
  57. data/lib/bcdd/result/{transitions → event_logs}/tracking/enabled.rb +15 -13
  58. data/lib/bcdd/result/{transitions → event_logs}/tracking.rb +4 -3
  59. data/lib/bcdd/result/{transitions → event_logs}/tree.rb +27 -11
  60. data/lib/bcdd/result/event_logs.rb +27 -0
  61. data/lib/bcdd/result/failure.rb +1 -3
  62. data/lib/bcdd/result/success.rb +1 -3
  63. data/lib/bcdd/result/version.rb +1 -1
  64. data/lib/bcdd/result.rb +23 -191
  65. data/lib/bcdd/success.rb +23 -0
  66. data/sig/bcdd/context.rbs +175 -0
  67. data/sig/bcdd/failure.rbs +13 -0
  68. data/sig/bcdd/result/config.rbs +1 -3
  69. data/sig/bcdd/result/context.rbs +2 -174
  70. data/sig/bcdd/result/contract.rbs +1 -0
  71. data/sig/bcdd/result/{transitions.rbs → event_logs.rbs} +19 -19
  72. data/sig/bcdd/result.rbs +13 -31
  73. data/sig/bcdd/success.rbs +13 -0
  74. metadata +41 -24
  75. data/examples/multiple_listeners/lib/bcdd/result/transitions_record.rb +0 -28
  76. data/examples/multiple_listeners/lib/transitions_listener/stdout.rb +0 -54
  77. data/lib/bcdd/result/context/failure.rb +0 -9
  78. data/lib/bcdd/result/context.rb +0 -93
  79. data/lib/bcdd/result/failure/methods.rb +0 -21
  80. data/lib/bcdd/result/success/methods.rb +0 -21
  81. data/lib/bcdd/result/transitions.rb +0 -27
@@ -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
@@ -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,7 +13,7 @@ class BCDD::Result::Config
15
13
  def initialize: -> void
16
14
 
17
15
  def and_then!: () -> BCDD::Result::CallableAndThen::Config
18
- def transitions: () -> BCDD::Result::Transitions::Config
16
+ def event_logs: () -> BCDD::Result::EventLogs::Config
19
17
 
20
18
  def freeze: -> BCDD::Result::Config
21
19
  def options: -> Hash[Symbol, BCDD::Result::Config::Switcher]
@@ -1,175 +1,3 @@
1
- class BCDD::Result::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::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 Error < BCDD::Result::Error
33
- class InvalidExposure < BCDD::Result::Context::Error
34
- end
35
- end
36
- end
37
-
38
- class BCDD::Result::Context
39
- class Success < BCDD::Result::Context
40
- include BCDD::Result::Success::Methods
41
-
42
- FetchValues: Proc
43
-
44
- def and_expose: (Symbol, Array[Symbol], terminal: bool) -> BCDD::Result::Context::Success
45
- end
46
-
47
- def self.Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
48
- end
49
-
50
- module BCDD::Result::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::Result::Context
64
-
65
- private
66
-
67
- def self.call_proc!: (
68
- untyped source,
69
- Hash[Symbol, untyped] value,
70
- nil injected_value
71
- ) -> BCDD::Result::Context
72
-
73
- def self.call_method!: (
74
- untyped source,
75
- Method method,
76
- Hash[Symbol, untyped] value,
77
- nil injected_value
78
- ) -> BCDD::Result::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::Result::Context result
89
- ) -> BCDD::Result::Context
90
-
91
- def self.expected_result_object: () -> singleton(BCDD::Result::Context)
92
-
93
- def self.expected_outcome: () -> String
94
- end
95
- end
96
-
97
- class BCDD::Result::Context
98
- class Failure < BCDD::Result::Context
99
- include BCDD::Result::Failure::Methods
100
-
101
- def and_expose: (Symbol, Array[Symbol], **untyped) -> BCDD::Result::Context::Failure
102
- end
103
-
104
- def self.Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
105
- end
106
-
107
- class BCDD::Result::Context
108
- module Mixin
109
- Factory: singleton(BCDD::Result::Mixin::Factory)
110
-
111
- module Methods
112
- def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
113
-
114
- def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
115
-
116
- private
117
-
118
- def _ResultAs: (singleton(BCDD::Result::Context), Symbol, untyped, ?terminal: bool) -> untyped
119
- end
120
-
121
- module Addons
122
- module Continue
123
- include BCDD::Result::Context::Mixin::Methods
124
-
125
- private
126
-
127
- def Continue: (**untyped) -> BCDD::Result::Context::Success
128
- end
129
-
130
- module Given
131
- include BCDD::Result::Context::Mixin::Methods
132
-
133
- private
134
-
135
- def Given: (*untyped) -> BCDD::Result::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::Result::Context::Mixin)
145
-
146
- def self.result_factory: -> singleton(BCDD::Result::Context)
147
- end
148
-
149
- class BCDD::Result::Context::Expectations < BCDD::Result::Expectations
150
- def self.mixin_module: -> singleton(BCDD::Result::Context::Expectations::Mixin)
151
-
152
- def self.result_factory_without_expectations: -> singleton(BCDD::Result)
153
-
154
- def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
155
- def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
156
- end
157
-
158
- module BCDD::Result::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::Result::Context::Success
165
- end
166
-
167
- module Given
168
- private def Given: (*untyped) -> BCDD::Result::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
1
+ class BCDD::Result
2
+ Context: BCDD::Context
175
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
@@ -1,14 +1,14 @@
1
1
  class BCDD::Result
2
- module Transitions
2
+ module EventLogs
3
3
  module Listener
4
4
  module ClassMethods
5
5
  def around_and_then?: () -> bool
6
- def around_transitions?: () -> bool
6
+ def around_event_logs?: () -> bool
7
7
  end
8
8
 
9
9
  extend ClassMethods
10
10
 
11
- def around_transitions: (scope: Hash[Symbol, untyped]) { () -> untyped } -> untyped
11
+ def around_event_logs: (scope: Hash[Symbol, untyped]) { () -> untyped } -> untyped
12
12
 
13
13
  def on_start: (scope: Hash[Symbol, untyped]) -> untyped
14
14
 
@@ -16,9 +16,9 @@ class BCDD::Result
16
16
 
17
17
  def on_record: (record: Hash[Symbol, untyped] ) -> untyped
18
18
 
19
- def on_finish: (transitions: Hash[Symbol, untyped] ) -> untyped
19
+ def on_finish: (event_logs: Hash[Symbol, untyped] ) -> untyped
20
20
 
21
- def before_interruption: (exception: ::Exception, transitions: Hash[Symbol, untyped]) -> untyped
21
+ def before_interruption: (exception: ::Exception, event_logs: Hash[Symbol, untyped]) -> untyped
22
22
  end
23
23
 
24
24
  class Listeners
@@ -40,11 +40,11 @@ class BCDD::Result
40
40
 
41
41
  private attr_reader listeners: Array[Listener]
42
42
  private attr_reader around_and_then_listener: untyped
43
- private attr_reader around_transitions_listener: untyped
43
+ private attr_reader around_event_logs_listener: untyped
44
44
 
45
45
  def initialize: (Array[Listener], untyped, untyped) -> void
46
46
 
47
- def around_transitions: (scope: Hash[Symbol, untyped]) { () -> untyped } -> untyped
47
+ def around_event_logs: (scope: Hash[Symbol, untyped]) { () -> untyped } -> untyped
48
48
 
49
49
  def on_start: (scope: Hash[Symbol, untyped]) -> untyped
50
50
 
@@ -52,9 +52,9 @@ class BCDD::Result
52
52
 
53
53
  def on_record: (record: Hash[Symbol, untyped] ) -> untyped
54
54
 
55
- def on_finish: (transitions: Hash[Symbol, untyped] ) -> untyped
55
+ def on_finish: (event_logs: Hash[Symbol, untyped] ) -> untyped
56
56
 
57
- def before_interruption: (exception: ::Exception, transitions: Hash[Symbol, untyped]) -> untyped
57
+ def before_interruption: (exception: ::Exception, event_logs: Hash[Symbol, untyped]) -> untyped
58
58
  end
59
59
 
60
60
  module Listener::Null
@@ -64,8 +64,6 @@ class BCDD::Result
64
64
  end
65
65
 
66
66
  class Config
67
- include ::Singleton
68
-
69
67
  attr_reader listener: untyped
70
68
  attr_reader trace_id: ::Proc
71
69
 
@@ -115,24 +113,26 @@ class BCDD::Result
115
113
  def move_down!: (?Integer level) -> Tree
116
114
  def move_to_root!: () -> Tree
117
115
 
118
- NestedIds: ^(Node) -> Array[untyped]
119
-
120
- def nested_ids: () -> Array[untyped]
121
-
116
+ Ids: ^(Node) -> Array[untyped]
122
117
  IdsMatrix: ::Proc
118
+ IdsLevelParent: ::Proc
123
119
 
120
+ def ids: () -> Array[untyped]
121
+ def ids_list: () -> Array[Integer]
124
122
  def ids_matrix: () -> untyped
123
+ def ids_level_parent: () -> untyped
125
124
  end
126
125
 
127
126
  module Tracking
128
127
  EMPTY_ARRAY: Array[untyped]
129
128
  EMPTY_HASH: Hash[untyped, untyped]
130
- EMPTY_TREE: Transitions::Tree
129
+ EMPTY_TREE: EventLogs::Tree
130
+ EMPTY_IDS: Hash[untyped, untyped]
131
131
  VERSION: Integer
132
132
  EMPTY: Hash[Symbol, untyped]
133
133
 
134
134
  class Enabled
135
- private attr_accessor tree: Transitions::Tree
135
+ private attr_accessor tree: EventLogs::Tree
136
136
  private attr_accessor records: Array[Hash[Symbol, untyped]]
137
137
  private attr_accessor listener: untyped
138
138
  private attr_accessor root_started_at: Integer
@@ -146,7 +146,7 @@ class BCDD::Result
146
146
 
147
147
  private
148
148
 
149
- def start: (String, String) -> [Transitions::Tree::Node, Hash[Symbol, untyped]]
149
+ def start: (String, String) -> [EventLogs::Tree::Node, Hash[Symbol, untyped]]
150
150
  def finish: (untyped) -> untyped
151
151
 
152
152
  TreeNodeValueNormalizer: ^(Integer, Array[untyped]) -> untyped
@@ -158,7 +158,7 @@ class BCDD::Result
158
158
 
159
159
  def now_in_milliseconds: () -> Integer
160
160
 
161
- def map_transitions: () -> Hash[Symbol, untyped]
161
+ def map_event_logs: () -> Hash[Symbol, untyped]
162
162
 
163
163
  def build_listener: () -> Listener
164
164
  end
data/sig/bcdd/result.rbs CHANGED
@@ -1,16 +1,16 @@
1
1
  class BCDD::Result
2
2
  private attr_accessor unknown: bool
3
- private attr_writer transitions: Hash[Symbol, untyped]
3
+ private attr_writer event_logs: Hash[Symbol, untyped]
4
4
  private attr_reader type_checker: BCDD::Result::Contract::TypeChecker
5
5
 
6
6
  attr_reader data: BCDD::Result::Data
7
7
  attr_reader source: untyped
8
8
  attr_reader terminal: bool
9
- attr_reader transitions: Hash[Symbol, untyped]
9
+ attr_reader event_logs: Hash[Symbol, untyped]
10
10
 
11
11
  def self.config: -> BCDD::Result::Config
12
12
  def self.configuration: (freeze: bool) { (BCDD::Result::Config) -> void } -> (bool | BCDD::Result::Config)
13
- def self.transitions: (name: untyped, desc: untyped) { () -> untyped } -> BCDD::Result
13
+ def self.event_logs: (name: untyped, desc: untyped) { () -> untyped } -> BCDD::Result
14
14
 
15
15
  def initialize: (
16
16
  type: Symbol,
@@ -23,6 +23,7 @@ class BCDD::Result
23
23
  def type: -> Symbol
24
24
  def value: -> untyped
25
25
 
26
+ def type?: (Symbol | String) -> bool
26
27
  def terminal?: -> bool
27
28
  def success?: (?Symbol type) -> bool
28
29
  def failure?: (?Symbol type) -> bool
@@ -47,6 +48,11 @@ class BCDD::Result
47
48
  def deconstruct: -> [Symbol, [Symbol, untyped]]
48
49
  def deconstruct_keys: (Array[Symbol]) -> Hash[Symbol, Hash[Symbol, untyped]]
49
50
 
51
+ TYPE_AND_VALUE: Array[Symbol]
52
+
53
+ def method_missing: (Symbol, *untyped) { (untyped) -> untyped } -> untyped
54
+
55
+ alias is? type?
50
56
  alias eql? ==
51
57
  alias on_type on
52
58
 
@@ -64,40 +70,16 @@ end
64
70
 
65
71
  class BCDD::Result
66
72
  class Success < BCDD::Result
67
- module Methods
68
- def success?: (?Symbol type) -> bool
69
- def failure?: (?Symbol type) -> bool
70
- def value_or: { () -> untyped } -> untyped
71
- def value: -> untyped
72
-
73
- private
74
-
75
- def kind: -> Symbol
76
- def type_checker: -> BCDD::Result::Contract::TypeChecker
77
- end
78
-
79
- include Methods
73
+ include BCDD::Success
80
74
  end
81
75
 
82
- def self.Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure
76
+ def self.Success: (Symbol type, ?untyped value) -> BCDD::Result::Success
83
77
  end
84
78
 
85
79
  class BCDD::Result
86
80
  class Failure < BCDD::Result
87
- module Methods
88
- def success?: (?Symbol type) -> bool
89
- def failure?: (?Symbol type) -> bool
90
- def value_or: { (untyped) -> untyped } -> untyped
91
- def value: -> untyped
92
-
93
- private
94
-
95
- def kind: -> Symbol
96
- def type_checker: -> BCDD::Result::Contract::TypeChecker
97
- end
98
-
99
- include Methods
81
+ include BCDD::Failure
100
82
  end
101
83
 
102
- def self.Success: (Symbol type, ?untyped value) -> BCDD::Result::Success
84
+ def self.Failure: (Symbol type, ?untyped value) -> BCDD::Result::Failure
103
85
  end
@@ -0,0 +1,13 @@
1
+ module BCDD
2
+ module Success
3
+ def success?: (?Symbol type) -> bool
4
+ def failure?: (?Symbol type) -> bool
5
+ def value_or: { () -> 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