You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+24-7Lines changed: 24 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,31 @@
1
1
-[\[Unreleased\]](#unreleased)
2
+
-[Changed](#changed)
2
3
-[\[0.11.0\] - 2024-01-02](#0110---2024-01-02)
3
4
-[Added](#added)
4
-
-[Changed](#changed)
5
+
-[Changed](#changed-1)
5
6
-[\[0.10.0\] - 2023-12-31](#0100---2023-12-31)
6
7
-[Added](#added-1)
7
8
-[\[0.9.1\] - 2023-12-12](#091---2023-12-12)
8
-
-[Changed](#changed-1)
9
+
-[Changed](#changed-2)
9
10
-[Fixed](#fixed)
10
11
-[\[0.9.0\] - 2023-12-12](#090---2023-12-12)
11
12
-[Added](#added-2)
12
-
-[Changed](#changed-2)
13
+
-[Changed](#changed-3)
13
14
-[\[0.8.0\] - 2023-12-11](#080---2023-12-11)
14
15
-[Added](#added-3)
15
-
-[Changed](#changed-3)
16
+
-[Changed](#changed-4)
16
17
-[Removed](#removed)
17
18
-[\[0.7.0\] - 2023-10-27](#070---2023-10-27)
18
19
-[Added](#added-4)
19
-
-[Changed](#changed-4)
20
+
-[Changed](#changed-5)
20
21
-[\[0.6.0\] - 2023-10-11](#060---2023-10-11)
21
22
-[Added](#added-5)
22
-
-[Changed](#changed-5)
23
+
-[Changed](#changed-6)
23
24
-[\[0.5.0\] - 2023-10-09](#050---2023-10-09)
24
25
-[Added](#added-6)
25
26
-[\[0.4.0\] - 2023-09-28](#040---2023-09-28)
26
27
-[Added](#added-7)
27
-
-[Changed](#changed-6)
28
+
-[Changed](#changed-7)
28
29
-[Removed](#removed-1)
29
30
-[\[0.3.0\] - 2023-09-26](#030---2023-09-26)
30
31
-[Added](#added-8)
@@ -36,6 +37,14 @@
36
37
37
38
## [Unreleased]
38
39
40
+
### Changed
41
+
42
+
-**(BREAKING)** Renames the subject concept/term to `source`. When a mixin is included/extended, it defines the `Success()` and `Failure()` methods. Since the results are generated in a context (instance or singleton where the mixin was used), they will have a defined source (instance or singleton itself).
43
+
> Definition of source
44
+
>
45
+
> From dictionary:
46
+
> * a place, person, or thing from which something comes or can be obtained.
47
+
39
48
## [0.11.0] - 2024-01-02
40
49
41
50
### Added
@@ -45,6 +54,14 @@
45
54
### Changed
46
55
47
56
-**(BREAKING)** Rename halted concept to terminal. Failures are terminal by default, but you can make a success terminal by enabling the `:continue` addon.
57
+
> Definition of terminal
58
+
>
59
+
> From dictionary:
60
+
> * of, forming, or situated at the end or extremity of something.
61
+
> * the end of a railroad or other transport route, or a station at such a point.
62
+
>
63
+
> From Wikipedia:
64
+
> * A "terminus" or "terminal" is a station at the end of a railway line.
48
65
49
66
-**(BREAKING)** Rename `BCDD::Result::Context::Success#and_expose` halted keyword argument to `terminal`.
Copy file name to clipboardExpand all lines: README.md
+18-17Lines changed: 18 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -649,9 +649,9 @@ Divide.call(2, 2)
649
649
650
650
This method generates a module that any object can include or extend. It adds two methods to the target object: `Success()` and `Failure()`.
651
651
652
-
The main difference between these methods and `BCDD::Result::Success()`/`BCDD::Result::Failure()` is that the former will utilize the target object (which has received the include/extend) as the result's subject.
652
+
The main difference between these methods and `BCDD::Result::Success()`/`BCDD::Result::Failure()` is that the former will utilize the target object (which has received the include/extend) as the result's source.
653
653
654
-
Because the result has a subject, the `#and_then` method can call methods from it.
654
+
Because the result has a source, the `#and_then` method can call methods from it.
655
655
656
656
##### Class example (Instance Methods)
657
657
@@ -746,9 +746,9 @@ Divide.call(4, '2') #<BCDD::Result::Failure type=:invalid_arg value="arg2 must b
746
746
747
747
To use the `#and_then` method to call methods, they must use `Success()` and `Failure()` to produce the results.
748
748
749
-
If you try to use `BCDD::Result::Subject()`/`BCDD::Result::Failure()`, or results from another `BCDD::Result.mixin` instance with `#and_then`, it will raise an error because the subjects will be different.
749
+
If you try to use `BCDD::Result::Success()`/`BCDD::Result::Failure()`, or results from another `BCDD::Result.mixin` instance with `#and_then`, it will raise an error because the sources are different.
750
750
751
-
**Note:** You can still use the block syntax, but all the results must be produced by the subject's `Success()` and `Failure()` methods.
751
+
**Note:** You can still use the block syntax, but all the results must be produced by the source's `Success()` and `Failure()` methods.
752
752
753
753
```ruby
754
754
moduleValidateNonzero
@@ -794,13 +794,13 @@ Look at the error produced by the code above:
794
794
```ruby
795
795
Divide.call(2, 0)
796
796
797
-
# You cannot call #and_then and return a result that does not belong to the subject! (BCDD::Result::Error::InvalidResultSubject)
798
-
# Expected subject: Divide
799
-
# Given subject: ValidateNonzero
797
+
# You cannot call #and_then and return a result that does not belong to the same source! (BCDD::Result::Error::InvalidResultSource)
798
+
# Expected source: Divide
799
+
# Given source: ValidateNonzero
800
800
# Given result: #<BCDD::Result::Failure type=:division_by_zero value="arg2 must not be zero">
801
801
```
802
802
803
-
In order to fix this, you must handle the result produced by `ValidateNonzero.call()` and return a result that belongs to the subject.
803
+
In order to fix this, you must handle the result produced by `ValidateNonzero.call()` and return a result that belongs to the same source.
804
804
805
805
```ruby
806
806
moduleValidateNonzero
@@ -832,7 +832,8 @@ module Divide
832
832
end
833
833
834
834
defvalidate_nonzero(numbers)
835
-
# In this case we are handling the other subject result and returning our own
835
+
# In this case we are handling the result from other source
836
+
# and returning our own
836
837
ValidateNonzero.call(numbers).handle do |on|
837
838
on.success { |numbers| Success(:ok, numbers) }
838
839
@@ -858,8 +859,8 @@ Divide.call(2, 0)
858
859
859
860
##### Dependency Injection
860
861
861
-
The `BCDD::Result#and_then` accepts a second argument that will be used to share a value with the subject's method.
862
-
To receive this argument, the subject's method must have an arity of two, where the first argument will be the result value and the second will be the shared value.
862
+
The `BCDD::Result#and_then` accepts a second argument that will be used to share a value with the source's method.
863
+
To receive this argument, the source's method must have an arity of two, where the first argument will be the result value and the second will be the injected value.
0 commit comments