granite 0.17.2 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/granite/action/performing.rb +1 -1
- data/lib/granite/action/preconditions.rb +6 -4
- data/lib/granite/action/transaction.rb +2 -2
- data/lib/granite/action.rb +2 -1
- data/lib/granite/version.rb +1 -1
- metadata +26 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f03af346280797b69bc67dd969cf8760409c39b5e8cdae7dfa9a4c806b668c4
|
4
|
+
data.tar.gz: 831e876dacdcd0f70ed08b078556a1bfb1e0950bdc8950c42e905343f2d4b05c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cebeba55e8e08f4d611216f9895dc7db83da2b2dc3775913579f6ba446c0df41e67ca2aef4559e6340a80c154697af73dbc1c91110a36751e47f7285389af1bc
|
7
|
+
data.tar.gz: f0266a8752670c3fec40e3d9ed4dd18e9dc9db03ae65b09b6187273e533f7be6fd45049374c9710f0fcabb91424397b27f98090b9a120d1a55e236e02dd7ea21
|
@@ -79,7 +79,7 @@ module Granite
|
|
79
79
|
# @raise [Granite::Action::ValidationError] Action or associated objects are invalid
|
80
80
|
# @raise [NotImplementedError] execute_perform! method was not defined yet
|
81
81
|
def try_perform!(context: nil, **options)
|
82
|
-
return unless satisfy_preconditions?
|
82
|
+
return unless satisfy_preconditions?(cache_result: true)
|
83
83
|
|
84
84
|
transaction do
|
85
85
|
validate!(context)
|
@@ -85,16 +85,17 @@ module Granite
|
|
85
85
|
|
86
86
|
def initialize(*)
|
87
87
|
@failed_preconditions = []
|
88
|
+
@preconditions_run = nil
|
88
89
|
super
|
89
90
|
end
|
90
91
|
|
91
92
|
# Check if all preconditions are satisfied
|
92
93
|
#
|
93
94
|
# @return [Boolean] wheter all preconditions are satisfied
|
94
|
-
def satisfy_preconditions?
|
95
|
+
def satisfy_preconditions?(cache_result: false)
|
95
96
|
errors.clear
|
96
97
|
failed_preconditions.clear
|
97
|
-
run_preconditions!
|
98
|
+
run_preconditions!(cache_result: cache_result)
|
98
99
|
end
|
99
100
|
|
100
101
|
# Adds passed error message and options to `errors` object
|
@@ -105,8 +106,9 @@ module Granite
|
|
105
106
|
|
106
107
|
private
|
107
108
|
|
108
|
-
def run_preconditions!
|
109
|
-
_preconditions.execute!
|
109
|
+
def run_preconditions!(cache_result: false)
|
110
|
+
_preconditions.execute!(self) if @preconditions_run.nil?
|
111
|
+
@preconditions_run = true if cache_result
|
110
112
|
errors.empty?
|
111
113
|
end
|
112
114
|
|
data/lib/granite/action.rb
CHANGED
@@ -38,7 +38,8 @@ module Granite
|
|
38
38
|
attributes = attributes.to_unsafe_hash if attributes.respond_to?(:to_unsafe_hash)
|
39
39
|
attributes = attributes.stringify_keys
|
40
40
|
attributes = attributes.merge(attributes.delete(model_name.param_key)) if attributes.key?(model_name.param_key)
|
41
|
-
|
41
|
+
|
42
|
+
super
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
data/lib/granite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: granite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toptal Engineering
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -266,14 +266,14 @@ dependencies:
|
|
266
266
|
requirements:
|
267
267
|
- - "~>"
|
268
268
|
- !ruby/object:Gem::Version
|
269
|
-
version: 1.
|
269
|
+
version: 1.65.1
|
270
270
|
type: :development
|
271
271
|
prerelease: false
|
272
272
|
version_requirements: !ruby/object:Gem::Requirement
|
273
273
|
requirements:
|
274
274
|
- - "~>"
|
275
275
|
- !ruby/object:Gem::Version
|
276
|
-
version: 1.
|
276
|
+
version: 1.65.1
|
277
277
|
- !ruby/object:Gem::Dependency
|
278
278
|
name: rubocop-rails
|
279
279
|
requirement: !ruby/object:Gem::Requirement
|
@@ -294,14 +294,28 @@ dependencies:
|
|
294
294
|
requirements:
|
295
295
|
- - "~>"
|
296
296
|
- !ruby/object:Gem::Version
|
297
|
-
version:
|
297
|
+
version: 3.0.1
|
298
298
|
type: :development
|
299
299
|
prerelease: false
|
300
300
|
version_requirements: !ruby/object:Gem::Requirement
|
301
301
|
requirements:
|
302
302
|
- - "~>"
|
303
303
|
- !ruby/object:Gem::Version
|
304
|
-
version:
|
304
|
+
version: 3.0.1
|
305
|
+
- !ruby/object:Gem::Dependency
|
306
|
+
name: rubocop-rspec_rails
|
307
|
+
requirement: !ruby/object:Gem::Requirement
|
308
|
+
requirements:
|
309
|
+
- - "~>"
|
310
|
+
- !ruby/object:Gem::Version
|
311
|
+
version: '2.30'
|
312
|
+
type: :development
|
313
|
+
prerelease: false
|
314
|
+
version_requirements: !ruby/object:Gem::Requirement
|
315
|
+
requirements:
|
316
|
+
- - "~>"
|
317
|
+
- !ruby/object:Gem::Version
|
318
|
+
version: '2.30'
|
305
319
|
- !ruby/object:Gem::Dependency
|
306
320
|
name: simplecov
|
307
321
|
requirement: !ruby/object:Gem::Requirement
|
@@ -316,8 +330,8 @@ dependencies:
|
|
316
330
|
- - "~>"
|
317
331
|
- !ruby/object:Gem::Version
|
318
332
|
version: '0.15'
|
319
|
-
description:
|
320
|
-
email:
|
333
|
+
description:
|
334
|
+
email:
|
321
335
|
executables: []
|
322
336
|
extensions: []
|
323
337
|
extra_rdoc_files: []
|
@@ -394,7 +408,7 @@ licenses:
|
|
394
408
|
- MIT
|
395
409
|
metadata:
|
396
410
|
rubygems_mfa_required: 'true'
|
397
|
-
post_install_message:
|
411
|
+
post_install_message:
|
398
412
|
rdoc_options: []
|
399
413
|
require_paths:
|
400
414
|
- lib
|
@@ -409,8 +423,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
409
423
|
- !ruby/object:Gem::Version
|
410
424
|
version: '0'
|
411
425
|
requirements: []
|
412
|
-
rubygems_version: 3.
|
413
|
-
signing_key:
|
426
|
+
rubygems_version: 3.4.10
|
427
|
+
signing_key:
|
414
428
|
specification_version: 4
|
415
429
|
summary: Another business actions architecture for Rails apps
|
416
430
|
test_files: []
|