state_machines-activerecord 0.31.0 → 0.40.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: cc3a76fe2fa39848f7ae9b5fc71c1fed9fae206a6cc0b0e24184415cdb760f1f
4
+ data.tar.gz: c8152e14110e863e478ec0dde3bac1a15e3cf15578deaae94e5f44062f1f67e8
5
5
  SHA512:
6
- metadata.gz: 4633127d19fc427f41ac5343be2c31c8cd11aed017b2511048dbeaacb9e18e8de17f94d2c65fd1effe49f057987269bb4d290bd23a4b8aa450b8ad1f3ec9b321
7
- data.tar.gz: 9e2443229c90ae33740efafe0e34f931cc8cb61d50fa72069b63ab4cc6e00677d282ff2f71c9a569c63928d5e2088bd4c8d4079e00ff061093937873e33c263c
6
+ metadata.gz: 982b654eb9d38edbe29bbaf2ca4f85980781575592813a4450e46cd4fbe1928f30ecc88e578aa4d879fcfb973109688fd90c942bb2a4e857420e5d94db14a602
7
+ data.tar.gz: ed2fae5f320b5f860beeca7c390e4674fd693b7ca171176a61f13e937039091cdd173a520438c1737e9ff4e2b936c91e89973ed64033635877cfcd04f4f13397
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.40.0'
7
7
  end
8
8
  end
9
9
  end
@@ -434,20 +434,29 @@ module StateMachines
434
434
  # Creates a scope for finding records *with* a particular state or
435
435
  # states for the attribute
436
436
  def create_with_scope(name)
437
- create_scope(name, ->(values) { ["#{attribute_column} IN (?)", values] })
437
+ attr_name = attribute
438
+ lambda do |klass, values|
439
+ if values.present?
440
+ klass.where(attr_name => values)
441
+ else
442
+ klass.all
443
+ end
444
+ end
438
445
  end
439
446
 
440
447
  # Creates a scope for finding records *without* a particular state or
441
448
  # states for the attribute
442
449
  def create_without_scope(name)
443
- create_scope(name, ->(values) { ["#{attribute_column} NOT IN (?)", values] })
450
+ attr_name = attribute
451
+ lambda do |klass, values|
452
+ if values.present?
453
+ klass.where.not(attr_name => values)
454
+ else
455
+ klass.all
456
+ end
457
+ end
444
458
  end
445
459
 
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
460
 
452
461
  # Runs a new database transaction, rolling back any changes by raising
453
462
  # an ActiveRecord::Rollback exception if the yielded block fails
@@ -466,10 +475,6 @@ module StateMachines
466
475
 
467
476
  private
468
477
 
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
478
 
474
479
  # Generates the results for the given scope based on one or more states to filter by
475
480
  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.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -16,14 +16,14 @@ 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
@@ -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
  - - ">="