state_machines-activerecord 0.31.0 → 0.100.0

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: 62bf9146491c433a75447414d5f9cfbab995f876eac289ddbca8ebf7dd9f6714
4
- data.tar.gz: 5cc62a238e1e450ec00f3f0091130dba47accf257cd1cf2759fa1b682442a09a
3
+ metadata.gz: 8da92c0d0872bf79ae81017dd5d16459e5222d10ee304390ddff3af14f1e1e05
4
+ data.tar.gz: c7ebd9fbdff4ee5bd2b0cca81b5daad186bb92157eddcb912829685571aa84eb
5
5
  SHA512:
6
- metadata.gz: 4633127d19fc427f41ac5343be2c31c8cd11aed017b2511048dbeaacb9e18e8de17f94d2c65fd1effe49f057987269bb4d290bd23a4b8aa450b8ad1f3ec9b321
7
- data.tar.gz: 9e2443229c90ae33740efafe0e34f931cc8cb61d50fa72069b63ab4cc6e00677d282ff2f71c9a569c63928d5e2088bd4c8d4079e00ff061093937873e33c263c
6
+ metadata.gz: 66d176f9efbc9d44ac2d5a5786f078e593d3590a99d855804ff4775649b18abae64264781f4ddc36a60ac253366aea0a9c02d3d1712d680d78fe443fffd437e7
7
+ data.tar.gz: f5e7a924679499d596439009b9bad2633af5389069959016595d31c44243f7551893cd2e53769e5e1b3a99b979f8d6ad1fa24d86caaa9134f0aa63528739b108
data/README.md CHANGED
@@ -2,9 +2,14 @@
2
2
 
3
3
  # StateMachines Active Record Integration
4
4
 
5
- The Active Record 5.1+ integration adds support for database transactions, automatically
5
+ The Active Record 7.2+ integration adds support for database transactions, automatically
6
6
  saving the record, named scopes, validation errors.
7
7
 
8
+ ## Requirements
9
+
10
+ - Ruby 3.2+
11
+ - Rails 7.2+
12
+
8
13
  ## Installation
9
14
 
10
15
  Add this line to your application's Gemfile:
@@ -3,7 +3,7 @@
3
3
  module StateMachines
4
4
  module Integrations
5
5
  module ActiveRecord
6
- VERSION = '0.31.0'
6
+ VERSION = '0.100.0'
7
7
  end
8
8
  end
9
9
  end
@@ -428,26 +428,36 @@ module StateMachines
428
428
 
429
429
  # Runs state events around the machine's :save action
430
430
  def around_save(object, &)
431
- object.class.state_machines.transitions(object, action).perform(&)
431
+ # Pass fiber: false to avoid deadlocks with ActiveRecord's LoadInterlockAwareMonitor
432
+ object.class.state_machines.transitions(object, action, fiber: false).perform(&)
432
433
  end
433
434
 
434
435
  # Creates a scope for finding records *with* a particular state or
435
436
  # states for the attribute
436
437
  def create_with_scope(name)
437
- create_scope(name, ->(values) { ["#{attribute_column} IN (?)", values] })
438
+ attr_name = attribute
439
+ lambda do |klass, values|
440
+ if values.present?
441
+ klass.where(attr_name => values)
442
+ else
443
+ klass.all
444
+ end
445
+ end
438
446
  end
439
447
 
440
448
  # Creates a scope for finding records *without* a particular state or
441
449
  # states for the attribute
442
450
  def create_without_scope(name)
443
- create_scope(name, ->(values) { ["#{attribute_column} NOT IN (?)", values] })
451
+ attr_name = attribute
452
+ lambda do |klass, values|
453
+ if values.present?
454
+ klass.where.not(attr_name => values)
455
+ else
456
+ klass.all
457
+ end
458
+ end
444
459
  end
445
460
 
446
- # Generates the fully-qualifed column name for this machine's attribute
447
- def attribute_column
448
- connection = owner_class.connection
449
- "#{connection.quote_table_name(owner_class.table_name)}.#{connection.quote_column_name(attribute)}"
450
- end
451
461
 
452
462
  # Runs a new database transaction, rolling back any changes by raising
453
463
  # an ActiveRecord::Rollback exception if the yielded block fails
@@ -466,10 +476,6 @@ module StateMachines
466
476
 
467
477
  private
468
478
 
469
- # Defines a new scope with the given name
470
- def create_scope(_name, scope)
471
- ->(model, values) { values.present? ? model.where(scope.call(values)) : model.all }
472
- end
473
479
 
474
480
  # Generates the results for the given scope based on one or more states to filter by
475
481
  def run_scope(scope, machine, klass, states)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machines-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.100.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '7.1'
19
+ version: '7.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '7.1'
26
+ version: '7.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: state_machines-activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.10.0
33
+ version: 0.100.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.10.0
40
+ version: 0.100.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: '3.1'
137
+ version: '3.2'
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - ">="