lite-command 1.3.2 → 1.4.0

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: 449d74c82b272492c3f8e2b4da2a0fd9c40a11ec06305feac435e89adf7090f4
4
- data.tar.gz: b52f0808caa73dfdb5b17b234c575c52857ecc4275fd409a66aeb24901410127
3
+ metadata.gz: 282197a645e710c42a8f5dc270014479fa140448bdda36763f50ae752a06c929
4
+ data.tar.gz: 2cb030c21fe0ee8c8fefe4e4d1d7d401721119ccc242d85ce79ccff1556134bc
5
5
  SHA512:
6
- metadata.gz: a2a0a961dd1789a2f464e3348bdf78c3e8a26d1b507c586a2e7c996d33829dbba4150090701cfe1363dcc400db1c5d2cecd2de81e43916d93a34600749062304
7
- data.tar.gz: 2f4ed6a45cd968e430924e039b9cd74babfed6bad3833f78d074fd7c11c7113cf1441e2393ed6bade77ce8f0fe484de5ba828eacc50e7bb2b4a32ea99203a0e6
6
+ metadata.gz: cfa99cd28ccf17132d77902bffdf0874202148e49a32d5d59656949cbcaf06191f4adda461e9d23eaaca65d6497ffc14e0d67cac98b7d8748d6465cd066bcc6c
7
+ data.tar.gz: 5466138b9894de3a53f95e999f752d41ba965ccd9bd171d8da43cdff234b51fdfbfdaa42db9a507c7f0242b5505d7f45ed78b5b6cf93e2ee36b614e885b2688f
data/CHANGELOG.md CHANGED
@@ -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.4.0] - 2021-09-04
10
+ ### Added
11
+ - Added `assign_and_return!` to propagation extension
12
+
9
13
  ## [1.3.2] - 2021-07-21
10
14
  ### Changed
11
15
  - Improved setup
data/Gemfile.lock CHANGED
@@ -1,32 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-command (1.3.2)
4
+ lite-command (1.4.0)
5
5
  lite-errors
6
6
  lite-memoize
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.1.4)
12
- actionview (= 6.1.4)
13
- activesupport (= 6.1.4)
11
+ actionpack (6.1.4.1)
12
+ actionview (= 6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
14
  rack (~> 2.0, >= 2.0.9)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.1.4)
19
- activesupport (= 6.1.4)
18
+ actionview (6.1.4.1)
19
+ activesupport (= 6.1.4.1)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activemodel (6.1.4)
25
- activesupport (= 6.1.4)
26
- activerecord (6.1.4)
27
- activemodel (= 6.1.4)
28
- activesupport (= 6.1.4)
29
- activesupport (6.1.4)
24
+ activemodel (6.1.4.1)
25
+ activesupport (= 6.1.4.1)
26
+ activerecord (6.1.4.1)
27
+ activemodel (= 6.1.4.1)
28
+ activesupport (= 6.1.4.1)
29
+ activesupport (6.1.4.1)
30
30
  concurrent-ruby (~> 1.0, >= 1.0.2)
31
31
  i18n (>= 1.6, < 2)
32
32
  minitest (>= 5.1)
@@ -53,18 +53,18 @@ GEM
53
53
  railties (>= 3.0.0)
54
54
  i18n (1.8.10)
55
55
  concurrent-ruby (~> 1.0)
56
- lite-errors (1.2.0)
57
- lite-memoize (1.1.0)
58
- loofah (2.10.0)
56
+ lite-errors (1.2.1)
57
+ lite-memoize (1.1.1)
58
+ loofah (2.12.0)
59
59
  crass (~> 1.0.2)
60
60
  nokogiri (>= 1.5.9)
61
61
  method_source (1.0.0)
62
- mini_portile2 (2.5.3)
62
+ mini_portile2 (2.6.1)
63
63
  minitest (5.14.4)
64
- nokogiri (1.11.7)
65
- mini_portile2 (~> 2.5.0)
64
+ nokogiri (1.12.4)
65
+ mini_portile2 (~> 2.6.1)
66
66
  racc (~> 1.4)
67
- parallel (1.20.1)
67
+ parallel (1.20.2)
68
68
  parser (3.0.2.0)
69
69
  ast (~> 2.4.1)
70
70
  racc (1.5.2)
@@ -74,11 +74,11 @@ GEM
74
74
  rails-dom-testing (2.0.3)
75
75
  activesupport (>= 4.2.0)
76
76
  nokogiri (>= 1.6)
77
- rails-html-sanitizer (1.3.0)
77
+ rails-html-sanitizer (1.4.2)
78
78
  loofah (~> 2.3)
79
- railties (6.1.4)
80
- actionpack (= 6.1.4)
81
- activesupport (= 6.1.4)
79
+ railties (6.1.4.1)
80
+ actionpack (= 6.1.4.1)
81
+ activesupport (= 6.1.4.1)
82
82
  method_source
83
83
  rake (>= 0.13)
84
84
  thor (~> 1.0)
@@ -99,18 +99,18 @@ GEM
99
99
  diff-lcs (>= 1.2.0, < 2.0)
100
100
  rspec-support (~> 3.10.0)
101
101
  rspec-support (3.10.2)
102
- rubocop (1.18.3)
102
+ rubocop (1.20.0)
103
103
  parallel (~> 1.10)
104
104
  parser (>= 3.0.0.0)
105
105
  rainbow (>= 2.2.2, < 4.0)
106
106
  regexp_parser (>= 1.8, < 3.0)
107
107
  rexml
108
- rubocop-ast (>= 1.7.0, < 2.0)
108
+ rubocop-ast (>= 1.9.1, < 2.0)
109
109
  ruby-progressbar (~> 1.7)
110
110
  unicode-display_width (>= 1.4.0, < 3.0)
111
- rubocop-ast (1.8.0)
111
+ rubocop-ast (1.11.0)
112
112
  parser (>= 3.0.1.1)
113
- rubocop-performance (1.11.4)
113
+ rubocop-performance (1.11.5)
114
114
  rubocop (>= 1.7.0, < 2.0)
115
115
  rubocop-ast (>= 0.4.0)
116
116
  rubocop-rake (0.6.0)
@@ -119,7 +119,7 @@ GEM
119
119
  rubocop (~> 1.0)
120
120
  rubocop-ast (>= 1.1.0)
121
121
  ruby-progressbar (1.11.0)
122
- ruby_parser (3.16.0)
122
+ ruby_parser (3.17.0)
123
123
  sexp_processor (~> 4.15, >= 4.15.1)
124
124
  sexp_processor (4.15.3)
125
125
  sqlite3 (1.4.2)
@@ -148,4 +148,4 @@ DEPENDENCIES
148
148
  sqlite3
149
149
 
150
150
  BUNDLED WITH
151
- 2.2.24
151
+ 2.2.26
data/README.md CHANGED
@@ -225,8 +225,12 @@ user_model.merge_errors!(command, direction: :to)
225
225
  Propagation methods help you perform an action on an object. If successful is
226
226
  returns the result else it adds the object errors to the form object. Available
227
227
  propagation methods are:
228
- `create_and_return!(object, params)`, `update_and_return!(object, params)`,
229
- `save_and_return!(object)`, and `destroy_and_return!(object)`
228
+ - `assign_and_return!(object, params)`
229
+ - `create_and_return!(klass, params)`
230
+ - `update_and_return!(object, params)`
231
+ - `destroy_and_return!(object)`
232
+ - `archive_and_return!(object)` (if using Lite::Archive)
233
+ - `save_and_return!(object)`
230
234
 
231
235
  ```ruby
232
236
  class SearchMovies < Lite::Command::Complex
@@ -7,11 +7,10 @@ module Lite
7
7
 
8
8
  private
9
9
 
10
- %i[archive destroy save].each do |action|
11
- define_method("#{action}_and_return!") do |klass|
12
- merge_errors!(klass) unless klass.send(action)
13
- klass
14
- end
10
+ def assign_and_return!(instance, params)
11
+ instance = instance.assign_attributes(params)
12
+ errors.merge!(instance.errors) unless instance.valid?
13
+ instance
15
14
  end
16
15
 
17
16
  def create_and_return!(klass, params)
@@ -20,9 +19,16 @@ module Lite
20
19
  klass
21
20
  end
22
21
 
23
- def update_and_return!(klass, params)
24
- merge_errors!(klass) unless klass.update(params)
25
- klass
22
+ def update_and_return!(instance, params)
23
+ merge_errors!(instance) unless instance.update(params)
24
+ instance
25
+ end
26
+
27
+ %i[archive destroy save].each do |action|
28
+ define_method("#{action}_and_return!") do |instance|
29
+ merge_errors!(instance) unless instance.send(action)
30
+ instance
31
+ end
26
32
  end
27
33
 
28
34
  end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Command
5
5
 
6
- VERSION = '1.3.2'
6
+ VERSION = '1.4.0'
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-22 00:00:00.000000000 Z
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lite-errors
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  - !ruby/object:Gem::Version
263
263
  version: '0'
264
264
  requirements: []
265
- rubygems_version: 3.2.24
265
+ rubygems_version: 3.2.26
266
266
  signing_key:
267
267
  specification_version: 4
268
268
  summary: Ruby Command based framework (aka service objects)