dry-mutations 0.8.42 → 0.8.90
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 +16 -1
- data/lib/dry/mutations.rb +2 -0
- data/lib/dry/mutations/dsl/schema.rb +17 -15
- data/lib/dry/mutations/extensions/outcome.rb +1 -1
- data/lib/dry/mutations/globals.rb +13 -0
- data/lib/dry/mutations/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae14dd7a88afccf35f90e96c4e4ef7cc874ff753
|
|
4
|
+
data.tar.gz: 06931834f386c2884b0662df8fb138e06db3fc76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f36d9577cf790ae07117116d7382f3615080ae0fb4da93e75293571a741014a2b42384ad13904ca3782813d06a7b775ab28ea29cfffb42caaaab64249060edd2
|
|
7
|
+
data.tar.gz: 4bb6c87803ef639bd493f82d3e88c1fb5923c1fc42574c21f6e78b7ce3afb7ed373e1d06b8f6d712e1c3e2f564cab364bf34adcc60903f81509b9698dc43a470
|
data/README.md
CHANGED
|
@@ -74,12 +74,27 @@ class ComposedMutation
|
|
|
74
74
|
extend ::Dry::Mutations::Transactions::DSL
|
|
75
75
|
chain do
|
|
76
76
|
validate ComposedValidation
|
|
77
|
-
|
|
77
|
+
transform ComposedTransform
|
|
78
78
|
mutate NestedMutation
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
### Call syntax
|
|
84
|
+
|
|
85
|
+
Basically, any call syntax is supported:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
# preferred
|
|
89
|
+
ComposedMutation.(input) # returns (Either ∨ Outcome) object
|
|
90
|
+
|
|
91
|
+
# legacy
|
|
92
|
+
ComposedMutation.run(input) # returns (Either ∨ Outcome) object
|
|
93
|
+
ComposedMutation.new(input).run # returns (Either ∨ Outcome) object
|
|
94
|
+
ComposedMutation.run!(input) # throws Mutation::ValidationException
|
|
95
|
+
ComposedMutation.new(input).run! # throws Mutation::ValidationException
|
|
96
|
+
```
|
|
97
|
+
|
|
83
98
|
## Usage
|
|
84
99
|
|
|
85
100
|
### Enable extensions for the specific mutation’s command
|
data/lib/dry/mutations.rb
CHANGED
|
@@ -14,6 +14,8 @@ require 'dry/mutations/dsl'
|
|
|
14
14
|
require 'dry/mutations/extensions'
|
|
15
15
|
require 'dry/mutations/transactions'
|
|
16
16
|
|
|
17
|
+
require 'dry/mutations/globals'
|
|
18
|
+
|
|
17
19
|
module Dry
|
|
18
20
|
# A dry implementation of mutations interface introduced by
|
|
19
21
|
# [Jonathan Novak](mailto:jnovak@gmail.com) in
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
module Dry
|
|
2
2
|
module Mutations
|
|
3
|
-
module DSL
|
|
3
|
+
module DSL # :nodoc:
|
|
4
|
+
MESSAGES_FILE = (::File.join __dir__, '..', '..', '..', '..', 'config', 'messages.yml').freeze
|
|
5
|
+
|
|
6
|
+
def self.Schema
|
|
7
|
+
Validation.Schema do
|
|
8
|
+
configure do
|
|
9
|
+
# config.messages = :i18n
|
|
10
|
+
config.messages_file = MESSAGES_FILE
|
|
11
|
+
config.hash_type = :symbolized
|
|
12
|
+
config.input_processor = :sanitizer
|
|
13
|
+
|
|
14
|
+
predicates(Mutations::Predicates)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
4
19
|
module Schema # :nodoc:
|
|
5
20
|
def schema
|
|
6
21
|
@schema ||= derived_schema
|
|
@@ -18,20 +33,7 @@ module Dry
|
|
|
18
33
|
next if [this, ::Mutations::Command, ::Dry::Mutations::Extensions::Command].include?(klazz)
|
|
19
34
|
klazz.respond_to?(:schema) && klazz.schema.is_a?(Validation::Schema)
|
|
20
35
|
end
|
|
21
|
-
parent_with_schema ? Class.new(parent_with_schema.schema.class).new :
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def empty_schema
|
|
25
|
-
Validation.Schema do
|
|
26
|
-
configure do
|
|
27
|
-
# config.messages = :i18n
|
|
28
|
-
config.messages_file = ::File.join __dir__, '..', '..', '..', '..', 'config', 'messages.yml'
|
|
29
|
-
config.hash_type = :symbolized
|
|
30
|
-
config.input_processor = :sanitizer
|
|
31
|
-
|
|
32
|
-
predicates(Mutations::Predicates)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
36
|
+
parent_with_schema ? Class.new(parent_with_schema.schema.class).new : ::Dry::Mutations::DSL::Schema()
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.90
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aleksei Matiushkin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -217,6 +217,7 @@ files:
|
|
|
217
217
|
- lib/dry/mutations/extensions/command.rb
|
|
218
218
|
- lib/dry/mutations/extensions/dummy.rb
|
|
219
219
|
- lib/dry/mutations/extensions/outcome.rb
|
|
220
|
+
- lib/dry/mutations/globals.rb
|
|
220
221
|
- lib/dry/mutations/monkeypatches.rb
|
|
221
222
|
- lib/dry/mutations/predicates.rb
|
|
222
223
|
- lib/dry/mutations/transactions.rb
|