lite-command 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/lite/command/extensions/errors.rb +7 -0
- data/lib/lite/command/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 507cd8928a28caa9421cef21d3f9991328e63bbf916ba4d46f3ed45f8f9d2796
|
4
|
+
data.tar.gz: a4d88123a92139411e2611063096efc32d78762de54c5577ff226ad4c831825c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c94deb0f0e15a6cbea7dfd1d0baa3a973b41c82ff1b3beafb2c15abeaecb0b898bf1e80ba7b19e1bf83fb3672e6a11895a5f0bd166aeceb2a8705a8b295a6b5
|
7
|
+
data.tar.gz: d2772122af7e6182a494cd3bfef0dff73b1e52ed52826c1dd721e91ac2ad40e7276c2192349fcb3c2c83aa78f707c24b014fb408ed82d7d442a3d8ec5ef4d8a7
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -186,6 +186,11 @@ command.failure? #=> Checks that it has been called and has errors
|
|
186
186
|
command.status #=> :failure
|
187
187
|
|
188
188
|
command.result! #=> Raises Lite::Command::ValidationError if it has any errors, if not it returns the result
|
189
|
+
|
190
|
+
# Use the following to merge errors from other commands or models
|
191
|
+
# with the default direction being `:from`
|
192
|
+
command.merge_errors!(command_2)
|
193
|
+
user_model.merge_errors!(command, direction: :to)
|
189
194
|
```
|
190
195
|
|
191
196
|
### Memoize (optional)
|
@@ -45,6 +45,13 @@ module Lite
|
|
45
45
|
called? && errored?
|
46
46
|
end
|
47
47
|
|
48
|
+
def merge_errors!(klass, direction: :from)
|
49
|
+
case direction
|
50
|
+
when :from then errors.merge!(klass.errors)
|
51
|
+
when :to then klass.errors.merge!(errors)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
48
55
|
def result!
|
49
56
|
result if valid?
|
50
57
|
end
|
data/lib/lite/command/version.rb
CHANGED