dry-mutations 0.8.42 → 0.8.90

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 574b966ed7044ce4a1d715e1faa96d2ab198c969
4
- data.tar.gz: 6afbbfb65140106e6ba29dad52f5b27d188dd322
3
+ metadata.gz: ae14dd7a88afccf35f90e96c4e4ef7cc874ff753
4
+ data.tar.gz: 06931834f386c2884b0662df8fb138e06db3fc76
5
5
  SHA512:
6
- metadata.gz: 5dee422ed5e48379a58d66b8a5beb57a7c7cab0689b84f44e73e6fbd963ccd986b2ead2b5880039f6ad4244e9f84ca84effe5e6efa4df12ea7d089e303dfc334
7
- data.tar.gz: d07ec776b41a590eb3f3ed2325e89b13fa52f3550e5e46dcce2d920cd532fd879765a21f8c4e0c189e02582e40d4e09a1c11b883c00c12c9498d3f986e640164
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
- validate ComposedTransform
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 : empty_schema
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
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  module Mutations
3
- module Extensions
3
+ module Extensions # :nodoc:
4
4
  module Outcome # :nodoc:
5
5
  include Dry::Monads::Either::Mixin
6
6
 
@@ -0,0 +1,13 @@
1
+ module Kernel # :nodoc:
2
+ def Outcome input
3
+ ::Dry::Mutations::Extensions.Outcome(input)
4
+ end
5
+
6
+ def Outcome! input
7
+ ::Dry::Mutations::Extensions.Outcome!(input)
8
+ end
9
+
10
+ def Schema
11
+ ::Dry::Mutations::DSL.Schema()
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Mutations
3
- VERSION = '0.8.42'.freeze
3
+ VERSION = '0.8.90'.freeze
4
4
  end
5
5
  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.42
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-07-20 00:00:00.000000000 Z
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