dry-mutations 0.99.99 → 0.99.100

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: 4342de6459871bd3ae00dd9b0fea1500670f4bed
4
- data.tar.gz: d41bc35fac90dd1c62e6de6f10799986f040db62
3
+ metadata.gz: ef60a2ff49f64d8a640292d1bb70e5ff52bc8cf8
4
+ data.tar.gz: 21c45010a109911e25d397994128ad3e5fe81ed1
5
5
  SHA512:
6
- metadata.gz: 802281f0490d6a6952161829781254921ef6e419a612bad392fb60273327e0260b39ebec43e0cf0ab3965566343620ebd3b4f7513847199f52528884d5c75770
7
- data.tar.gz: 030bf2c701e48049d47e2f07d023e9fca89cff8a9b368dbc6218b9bd41e7675c49fa90ce96e0afc03c66f5ba2f3e6875ad285c48993d4768928c1e48bafb4227
6
+ metadata.gz: faf1055254a03e47b49298b821c7d8a73f04dd616b776bb33dcf46548728e811e8d7145187e82dfa276615f3f77b4c5bb1892ec0f1fe17ad6322917423e10eda
7
+ data.tar.gz: be638ebe8f86ddcbf46dc1fd05e10ca9d68fc6b0c702014ed928fdae83e8f69b1c3ac60fd1f31417622b23c80eed549ea0305eeff60140987c0d571cc21f3fcf
@@ -3,7 +3,9 @@ rvm:
3
3
  - 2.1.1
4
4
  - 2.1.8
5
5
  - 2.2.2
6
- before_install: gem install bundler -v 1.10.6
6
+ - 2.3.1
7
+ - 2.4.0
8
+ before_install: gem install bundler -v 1.13.7
7
9
  addons:
8
10
  code_climate:
9
11
  repo_token: ebdc539bad445dc9ca96c4b01e2aa414624456bc47b3bf8b77c726c49b3158ba
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dry-mutations (0.99.99)
4
+ dry-mutations (0.99.100)
5
5
  activesupport (>= 3.2, < 5)
6
6
  dry-transaction (~> 0.9)
7
7
  dry-validation (~> 0.10)
@@ -11,9 +11,8 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (4.2.7.1)
14
+ activesupport (4.2.8)
15
15
  i18n (~> 0.7)
16
- json (~> 1.7, >= 1.7.7)
17
16
  minitest (~> 5.1)
18
17
  thread_safe (~> 0.3, >= 0.3.4)
19
18
  tzinfo (~> 1.1)
@@ -21,20 +20,20 @@ GEM
21
20
  codeclimate-test-reporter (1.0.3)
22
21
  simplecov
23
22
  coderay (1.1.1)
24
- concurrent-ruby (1.0.3)
23
+ concurrent-ruby (1.0.4)
25
24
  diff-lcs (1.2.5)
26
25
  docile (1.1.5)
27
- dry-configurable (0.4.0)
26
+ dry-configurable (0.6.1)
28
27
  concurrent-ruby (~> 1.0)
29
28
  dry-container (0.6.0)
30
29
  concurrent-ruby (~> 1.0)
31
30
  dry-configurable (~> 0.1, >= 0.1.3)
32
- dry-core (0.2.1)
31
+ dry-core (0.2.4)
33
32
  concurrent-ruby (~> 1.0)
34
33
  dry-equalizer (0.2.0)
35
- dry-logic (0.4.0)
34
+ dry-logic (0.4.1)
36
35
  dry-container (~> 0.2, >= 0.2.6)
37
- dry-core (~> 0.1)
36
+ dry-core (~> 0.2)
38
37
  dry-equalizer (~> 0.2)
39
38
  dry-matcher (0.6.0)
40
39
  dry-monads (0.2.1)
@@ -44,7 +43,7 @@ GEM
44
43
  dry-matcher (>= 0.5.0)
45
44
  dry-monads (>= 0.0.1)
46
45
  wisper (>= 1.6.0)
47
- dry-types (0.9.3)
46
+ dry-types (0.9.4)
48
47
  concurrent-ruby (~> 1.0)
49
48
  dry-configurable (~> 0.1)
50
49
  dry-container (~> 0.3)
@@ -52,21 +51,20 @@ GEM
52
51
  dry-equalizer (~> 0.2)
53
52
  dry-logic (~> 0.4, >= 0.4.0)
54
53
  inflecto (~> 0.0.0, >= 0.0.2)
55
- dry-validation (0.10.4)
54
+ dry-validation (0.10.5)
56
55
  concurrent-ruby (~> 1.0)
57
56
  dry-configurable (~> 0.1, >= 0.1.3)
58
- dry-container (~> 0.2, >= 0.2.8)
59
57
  dry-core (~> 0.2, >= 0.2.1)
60
58
  dry-equalizer (~> 0.2)
61
59
  dry-logic (~> 0.4, >= 0.4.0)
62
60
  dry-types (~> 0.9, >= 0.9.0)
63
- hashie (3.4.6)
64
- i18n (0.7.0)
61
+ hashie (3.5.5)
62
+ i18n (0.8.1)
65
63
  inflecto (0.0.2)
66
64
  json (1.8.3)
67
65
  method_source (0.8.2)
68
66
  minitest (5.10.1)
69
- mutations (0.8.0)
67
+ mutations (0.8.1)
70
68
  activesupport
71
69
  pry (0.10.4)
72
70
  coderay (~> 1.1.0)
@@ -92,7 +90,7 @@ GEM
92
90
  simplecov-html (~> 0.10.0)
93
91
  simplecov-html (0.10.0)
94
92
  slop (3.6.0)
95
- thread_safe (0.3.5)
93
+ thread_safe (0.3.6)
96
94
  tzinfo (1.2.2)
97
95
  thread_safe (~> 0.1)
98
96
  wisper (1.6.1)
@@ -111,4 +109,4 @@ DEPENDENCIES
111
109
  simplecov
112
110
 
113
111
  BUNDLED WITH
114
- 1.10.6
112
+ 1.13.7
data/README.md CHANGED
@@ -224,6 +224,34 @@ Class.new(::Mutations::Command) do
224
224
  end
225
225
  ```
226
226
 
227
+ ## Declare the resulting type of a schema
228
+
229
+ Using the approach above, one might start with a schema type declaration:
230
+
231
+ ```ruby
232
+ # this line must be a first declaration
233
+ schema(::Dry::Validation.Form {})
234
+
235
+ # now continue with generic `schema {}` blocks to append features:
236
+ schema do
237
+ required(:integer_value).filled(:int?, gt?: 0)
238
+ required(:date_value).filled(:date?)
239
+ required(:bool_value).filled(:bool?)
240
+ end
241
+ ```
242
+ see [`schema_spec.rb`](https://github.com/am-kantox/dry-mutations/blob/master/spec/dry/mutations/schema_spec.rb)
243
+ for an inspiration.
244
+
245
+ ### Subschema’s type
246
+
247
+ Startign with `0.99.100` we accept `type:` parameter in call to `schema`:
248
+
249
+ ```ruby
250
+ schema type: :form do
251
+ ...
252
+ end
253
+ ```
254
+
227
255
  ## Dealing with `outcome`
228
256
 
229
257
  ### Command
@@ -33,8 +33,10 @@ module Dry
33
33
  end
34
34
  end
35
35
 
36
- def self.Schema(input_processor: nil, **options, &block)
37
- ::Dry::Validation.Schema(::Dry::Mutations::Schema, **options) do
36
+ def self.Schema(input_processor: nil, type: :schema, **options, &block)
37
+ type = :schema unless type && ::Dry::Mutations.const_defined?(type.to_s.capitalize)
38
+ parent = ::Dry::Mutations.const_get(type.to_s.capitalize)
39
+ ::Dry::Validation.Schema(parent, **options) do
38
40
  configure { config.input_processor = input_processor } if input_processor
39
41
  instance_exec(&block) if block
40
42
  end
@@ -2,11 +2,12 @@ module Dry
2
2
  module Mutations
3
3
  module DSL # :nodoc:
4
4
  module Schema # :nodoc:
5
- def schema *args, input_processor: nil, **options, &block
5
+ def schema *args, input_processor: nil, type: :form, **options, &block
6
6
  case args.count
7
7
  when 0, 1
8
8
  schema, = args
9
- @schema ||= patched_schema(schema) || derived_schema(input_processor: input_processor, **options, &block)
9
+ @schema ||= patched_schema(schema) \
10
+ || derived_schema(input_processor: input_processor, type: type, **options, &block)
10
11
  return @schema unless block_given?
11
12
 
12
13
  @schema = Validation.Schema(@schema, **@schema.options, &Proc.new)
@@ -23,7 +24,7 @@ module Dry
23
24
 
24
25
  private
25
26
 
26
- def derived_schema input_processor: nil, **options, &block
27
+ def derived_schema input_processor:, type:, **options, &block
27
28
  this = is_a?(Class) ? self : self.class
28
29
 
29
30
  parent_with_schema = this.ancestors.drop(1).detect do |klazz|
@@ -34,7 +35,7 @@ module Dry
34
35
  if parent_with_schema
35
36
  Class.new(parent_with_schema.schema.class).new
36
37
  else
37
- ::Dry::Mutations.Schema(input_processor: input_processor, **options, &block)
38
+ ::Dry::Mutations.Schema(input_processor: input_processor, type: type, **options, &block)
38
39
  end
39
40
  end
40
41
 
@@ -0,0 +1,22 @@
1
+ module Dry
2
+ module Mutations
3
+ class Form < ::Dry::Validation::Form
4
+ @@discarded = []
5
+
6
+ configure(&::Dry::Validation::Schema::CONFIGURATOR)
7
+ # predicates(::Dry::Mutations::Predicates)
8
+
9
+ def discarded
10
+ @@discarded
11
+ end
12
+
13
+ def discarded?
14
+ discarded.empty?
15
+ end
16
+
17
+ def discarded! value
18
+ discarded << value
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Mutations
3
- VERSION = '0.99.99'.freeze
3
+ VERSION = '0.99.100'.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.99.99
4
+ version: 0.99.100
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-12-19 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -196,6 +196,7 @@ files:
196
196
  - lib/dry/mutations/extensions/command.rb
197
197
  - lib/dry/mutations/extensions/dummy.rb
198
198
  - lib/dry/mutations/extensions/outcome.rb
199
+ - lib/dry/mutations/form.rb
199
200
  - lib/dry/mutations/globals.rb
200
201
  - lib/dry/mutations/monkeypatches.rb
201
202
  - lib/dry/mutations/patches.rb