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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fa4bc02fc1806cb613a3d803cca96da5451905b
4
- data.tar.gz: 81c2ba3bfcbf356fbe4fe85b3260fdfa388f969d
3
+ metadata.gz: 574b966ed7044ce4a1d715e1faa96d2ab198c969
4
+ data.tar.gz: 6afbbfb65140106e6ba29dad52f5b27d188dd322
5
5
  SHA512:
6
- metadata.gz: f70755498be311d9acf031838b70d24e151a27f52367fa567e3e4d067590ed5c0963700568cc25b94f6d6cca7f09829998ff93055cdf9037baa8781602623c48
7
- data.tar.gz: db1fa05b824b4662c5cd36eaa63bf0a1a8541c2fbb59a6766d8f2d3602af50c572233ea27769b85e8593fdee892d4ab1ea41d966cf32da067eda5bd62d338daa
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
@@ -1,2 +1,3 @@
1
1
  require 'dry/mutations/extensions/command'
2
+ require 'dry/mutations/extensions/dummy'
2
3
  require 'dry/mutations/extensions/outcome'
@@ -0,0 +1,11 @@
1
+ module Dry
2
+ module Mutations
3
+ module Extensions
4
+ module Dummy # :nodoc:
5
+ def execute
6
+ inputs
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Mutations
3
- VERSION = '0.8.14'.freeze
3
+ VERSION = '0.8.42'.freeze
4
4
  end
5
5
  end
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.14
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