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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3e1ba1452b79b7af5130326fb9fd4b11399bf8c23d2bdcbb3cf7a3d54a81c6f
4
- data.tar.gz: dbc6e24fa6d5e22710bed7a24f0ff9bde67d91bc6672bb0af89477601ec1b199
3
+ metadata.gz: 0f03af346280797b69bc67dd969cf8760409c39b5e8cdae7dfa9a4c806b668c4
4
+ data.tar.gz: 831e876dacdcd0f70ed08b078556a1bfb1e0950bdc8950c42e905343f2d4b05c
5
5
  SHA512:
6
- metadata.gz: cfff687bb585d2ddff0fc504e08a849e3f148c13cfb9bb6d48a016dca0a83a57008cdce581753ccacb18005a5c9cac46ad49ebcacc3e615f14c9a7af4fc7aa90
7
- data.tar.gz: 77fa6fd1b0c27b045cca42ec681ae51e3042fa89c45c602bdd509f78126920da694d85582089805cf753ce9792aef21177ee9cfe745e268bd36e6be62b0094b5
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! self
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
 
@@ -13,12 +13,12 @@ module Granite
13
13
  def run_callbacks(event)
14
14
  if event.to_s == 'commit'
15
15
  begin
16
- super(event)
16
+ super
17
17
  rescue *handled_exceptions => e
18
18
  handle_exception(e)
19
19
  end
20
20
  else
21
- super(event)
21
+ super
22
22
  end
23
23
  end
24
24
 
@@ -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
- super(attributes)
41
+
42
+ super
42
43
  end
43
44
  end
44
45
 
@@ -1,3 +1,3 @@
1
1
  module Granite
2
- VERSION = '0.17.2'.freeze
2
+ VERSION = '0.17.3'.freeze
3
3
  end
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.2
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: 2024-05-27 00:00:00.000000000 Z
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.63.5
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.63.5
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: 2.29.2
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: 2.29.2
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.5.10
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: []