dry-mutations 0.8.14 → 0.8.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +54 -0
- data/lib/dry/mutations/extensions.rb +1 -0
- data/lib/dry/mutations/extensions/dummy.rb +11 -0
- data/lib/dry/mutations/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 574b966ed7044ce4a1d715e1faa96d2ab198c969
|
|
4
|
+
data.tar.gz: 6afbbfb65140106e6ba29dad52f5b27d188dd322
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5dee422ed5e48379a58d66b8a5beb57a7c7cab0689b84f44e73e6fbd963ccd986b2ead2b5880039f6ad4244e9f84ca84effe5e6efa4df12ea7d089e303dfc334
|
|
7
|
+
data.tar.gz: d07ec776b41a590eb3f3ed2325e89b13fa52f3550e5e46dcce2d920cd532fd879765a21f8c4e0c189e02582e40d4e09a1c11b883c00c12c9498d3f986e640164
|
data/README.md
CHANGED
|
@@ -26,6 +26,60 @@ Or install it yourself as:
|
|
|
26
26
|
|
|
27
27
|
$ gem install dry-mutations
|
|
28
28
|
|
|
29
|
+
## Was ⇒ Is
|
|
30
|
+
|
|
31
|
+
### Was
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
class ComposedMutation < Mutations::Command
|
|
35
|
+
...
|
|
36
|
+
def validate
|
|
37
|
+
additional_validate(input1, input2)
|
|
38
|
+
@nested = NestedMutation.new(inputs, input1: input1, input2: input2)
|
|
39
|
+
unless @nested.validation_outcome.success?
|
|
40
|
+
@nested.validation_outcome.errors.each do |key, error|
|
|
41
|
+
add_error(key.to_sym, error.symbolic, error.message)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def execute
|
|
47
|
+
@nested.run!
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Is
|
|
53
|
+
```ruby
|
|
54
|
+
class ComposedValidation < Mutations::Command
|
|
55
|
+
prepend ::Dry::Mutations::Extensions::Command
|
|
56
|
+
prepend ::Dry::Mutations::Extensions::Dummy
|
|
57
|
+
|
|
58
|
+
...
|
|
59
|
+
def validate
|
|
60
|
+
additional_validate(input1, input2)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class ComposedTransform < Mutations::Command
|
|
65
|
+
prepend ::Dry::Mutations::Extensions::Command
|
|
66
|
+
|
|
67
|
+
...
|
|
68
|
+
def execute
|
|
69
|
+
inputs.merge(input1: input1, input2: input2)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class ComposedMutation
|
|
74
|
+
extend ::Dry::Mutations::Transactions::DSL
|
|
75
|
+
chain do
|
|
76
|
+
validate ComposedValidation
|
|
77
|
+
validate ComposedTransform
|
|
78
|
+
mutate NestedMutation
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
29
83
|
## Usage
|
|
30
84
|
|
|
31
85
|
### Enable extensions for the specific mutation’s command
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-mutations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.42
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aleksei Matiushkin
|
|
@@ -215,6 +215,7 @@ files:
|
|
|
215
215
|
- lib/dry/mutations/errors/error_compiler.rb
|
|
216
216
|
- lib/dry/mutations/extensions.rb
|
|
217
217
|
- lib/dry/mutations/extensions/command.rb
|
|
218
|
+
- lib/dry/mutations/extensions/dummy.rb
|
|
218
219
|
- lib/dry/mutations/extensions/outcome.rb
|
|
219
220
|
- lib/dry/mutations/monkeypatches.rb
|
|
220
221
|
- lib/dry/mutations/predicates.rb
|