dry-mutations 0.99.0 → 0.99.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/lib/dry/mutations/extensions/command.rb +19 -1
- data/lib/dry/mutations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84498f83aab334053ceadcf35a12ab919af5fdb
|
4
|
+
data.tar.gz: 508f7a5805a93949d189a6dfe06148f456a25562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 711ab39269cf47bfaee78acc30daff353dc274f1450b2746fac79fd4b3d7a186d7b0d1ae97c060f075231bfbcf8075ce5fab7b34070ed70b50d4fcb22537708b
|
7
|
+
data.tar.gz: 777c72b07f23f37659ec2aa788220122e940bb2bf5cad9fa81b82854312b8b56839ef4b3785ddc66d896a0095edd7f02b411befdfa84864e406ffc44cc5cea12
|
data/README.md
CHANGED
@@ -112,7 +112,7 @@ class MyMutation < Mutations::Command
|
|
112
112
|
string :maturity_choice, in: %w(spot forward_days fixed_date)
|
113
113
|
optional do
|
114
114
|
hash :maturity_days_set do
|
115
|
-
integer :days # For spot or forward_days options
|
115
|
+
integer :days, default: 3 # For spot or forward_days options
|
116
116
|
end
|
117
117
|
hash :maturity_date_set do
|
118
118
|
date :date # When passing a fixed date
|
@@ -284,6 +284,20 @@ new functionality. This is untested in all possible environments.
|
|
284
284
|
|
285
285
|
Bug reports are very welcome!
|
286
286
|
|
287
|
+
## Changelog
|
288
|
+
|
289
|
+
#### 0.99.1
|
290
|
+
Support for direct input parameters invocation. 100%-compatibility with `mutations`:
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
def validate # input ≡ { date: nil }
|
294
|
+
date < Date.now
|
295
|
+
end
|
296
|
+
```
|
297
|
+
|
298
|
+
#### 0.99.0
|
299
|
+
Support for `default:` guard. 99%-compatibility with `mutations`
|
300
|
+
|
287
301
|
## Development
|
288
302
|
|
289
303
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -39,7 +39,7 @@ module Dry
|
|
39
39
|
|
40
40
|
@validation_result = discard_empty!
|
41
41
|
|
42
|
-
@inputs = Utils.Hash @validation_result.output
|
42
|
+
@inputs = fix_accessors Utils.Hash @validation_result.output
|
43
43
|
|
44
44
|
# dry: {:name=>["size cannot be greater than 10"],
|
45
45
|
# :properties=>{:first_arg=>["must be a string", "is in invalid format"]},
|
@@ -163,6 +163,24 @@ module Dry
|
|
163
163
|
end.compact.to_h
|
164
164
|
)
|
165
165
|
end
|
166
|
+
|
167
|
+
def fix_accessors hash
|
168
|
+
hash.each do |method, _|
|
169
|
+
next if respond_to?(name = method)
|
170
|
+
|
171
|
+
singleton_class.tap do |c|
|
172
|
+
c.send(:define_method, name) { @inputs[name] }
|
173
|
+
if c < Enumerable
|
174
|
+
c.send(:define_method, :"#{name}_present?") do
|
175
|
+
@inputs.key?(name) && !@inputs[name].empty?
|
176
|
+
end
|
177
|
+
else
|
178
|
+
c.send(:define_method, :"#{name}_present?") { @inputs.key?(name) }
|
179
|
+
c.send(:define_method, :"#{name}=") { |value| @inputs[name] = value }
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
166
184
|
end
|
167
185
|
end
|
168
186
|
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.
|
4
|
+
version: 0.99.1
|
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-
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|