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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1aa7ea6342f56811303cb6cc8a66b5e18111548090782212cafc3567c8dbd35a
4
- data.tar.gz: 28a8b68ec9dd2977cda7f393e35e63833a3f41fbff27893d6b68e4579a3d18b4
3
+ metadata.gz: 507cd8928a28caa9421cef21d3f9991328e63bbf916ba4d46f3ed45f8f9d2796
4
+ data.tar.gz: a4d88123a92139411e2611063096efc32d78762de54c5577ff226ad4c831825c
5
5
  SHA512:
6
- metadata.gz: 2c20e8692e9265e812aa384cdb85fff5fb1e1f6727478c1cbf3b665b2f1d23311d6cc9f173e2054f734a0eaf9d4df00d56433502bc8ae343357e8ecf8c54a0c1
7
- data.tar.gz: 2852a4135fddb7c6aae80791f0cfda298c0abb04b82c44373f342733589fe363c19df52cd6361983ec402a5c93cf405639858d300ded85920ced6f6f89e0f44b
6
+ metadata.gz: 3c94deb0f0e15a6cbea7dfd1d0baa3a973b41c82ff1b3beafb2c15abeaecb0b898bf1e80ba7b19e1bf83fb3672e6a11895a5f0bd166aeceb2a8705a8b295a6b5
7
+ data.tar.gz: d2772122af7e6182a494cd3bfef0dff73b1e52ed52826c1dd721e91ac2ad40e7276c2192349fcb3c2c83aa78f707c24b014fb408ed82d7d442a3d8ec5ef4d8a7
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.4] - 2019-09-02
10
+ ### Added
11
+ - Add `merge_errors!` method to errors module
12
+
9
13
  ## [1.0.3] - 2019-09-02
10
14
  ### Added
11
15
  - Add rails generators
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-command (1.0.3)
4
+ lite-command (1.0.4)
5
5
  lite-errors
6
6
  lite-memoize
7
7
 
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
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Command
5
5
 
6
- VERSION ||= '1.0.3'
6
+ VERSION ||= '1.0.4'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez