aasm 5.5.2 → 6.0.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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +9 -2
- data/lib/aasm/base.rb +9 -12
- data/lib/aasm/instance_base.rb +14 -5
- data/lib/aasm/localizer.rb +1 -1
- data/lib/aasm/persistence/active_record_persistence.rb +3 -12
- data/lib/aasm/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e626fca29f212e32825e19f264c131943d01c7cbb0fe28cf57b0d36fb32c2b4
|
|
4
|
+
data.tar.gz: c09bf7ab926dde3243a41ceb63af6586ce08a9e3979bad4a1908be35ad4a4a39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f91b491520bd43f49d6492dfd57a7f8c446e00808b56afcec9f42e4d5916d98c15930bc61525a28842e265e1dcfd2e0f35ba209b6c9c6d9490b99f2bc416b03
|
|
7
|
+
data.tar.gz: bcd5ef9226387afdc56cae5cf96c737ea71853b954a9435900c164746705d8904e9dcdae41830b6716fabe0d1e563d6ed1f9befab0660ffd04f15c9785227a32
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
## unreleased
|
|
4
|
+
* typo fixes, thanks @kumar-mithlesh [#870](https://github.com/aasm/aasm/pull/870)
|
|
5
|
+
|
|
6
|
+
## 6.0.0 (5 July 2026)
|
|
7
|
+
* Let `whiny_persistence: true` be the default now [#378](https://github.com/aasm/aasm/pull/378)
|
|
8
|
+
* Stopped support for Ruby v2 [#865](https://github.com/aasm/aasm/pull/865)
|
|
9
|
+
* Stopped support for Ruby on Rails v6 [#866](https://github.com/aasm/aasm/pull/866)
|
|
10
|
+
* Add MFA requirement to gemspec metadata [#879](https://github.com/aasm/aasm/pull/879)
|
|
11
|
+
* Avoid namespace naming collisions [#880](https://github.com/aasm/aasm/pull/880)
|
|
4
12
|
|
|
5
13
|
## 5.5.2 (22 October 2025)
|
|
6
14
|
* Fix another issue around keyword arguments for Ruby >3.2, thanks @segiddins [#873](https://github.com/aasm/aasm/pull/873)
|
|
@@ -233,7 +241,7 @@ to [waghanza](https://github.com/waghanza)
|
|
|
233
241
|
|
|
234
242
|
## 4.4.0
|
|
235
243
|
|
|
236
|
-
* add support global
|
|
244
|
+
* add support global transition callbacks (see [issue #221](https://github.com/aasm/aasm/issues/221) and [issue #253](https://github.com/aasm/aasm/issues/253) for details)
|
|
237
245
|
* add support (bugfix) for Mongoid >= 5.0 (see [issue #277](https://github.com/aasm/aasm/issues/277) and [issue #278](https://github.com/aasm/aasm/issues/278) for details)
|
|
238
246
|
|
|
239
247
|
## 4.3.0
|
data/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://codecov.io/gh/aasm/aasm)
|
|
7
7
|
|
|
8
8
|
## Index
|
|
9
|
+
- [Upgrade from version 5 to 6](#upgrade-from-version-5-to-6)
|
|
9
10
|
- [Upgrade from version 3 to 4](#upgrade-from-version-3-to-4)
|
|
10
11
|
- [Usage](#usage)
|
|
11
12
|
- [Callbacks](#callbacks)
|
|
@@ -59,6 +60,10 @@ AASM started as the *acts_as_state_machine* plugin but has evolved into a more g
|
|
|
59
60
|
that no longer targets only ActiveRecord models. It currently provides adapters for many
|
|
60
61
|
ORMs but it can be used for any Ruby class, no matter what parent class it has (if any).
|
|
61
62
|
|
|
63
|
+
## Upgrade from version 5 to 6
|
|
64
|
+
|
|
65
|
+
Take a look at the [README_FROM_VERSION_5_TO_6](https://github.com/aasm/aasm/blob/master/README_FROM_VERSION_5_TO_6.md) for details how to switch from version 5.x to 6.0 of _AASM_.
|
|
66
|
+
|
|
62
67
|
## Upgrade from version 3 to 4
|
|
63
68
|
|
|
64
69
|
Take a look at the [README_FROM_VERSION_3_TO_4](https://github.com/aasm/aasm/blob/master/README_FROM_VERSION_3_TO_4.md) for details how to switch from version 3.x to 4.0 of _AASM_.
|
|
@@ -535,7 +540,9 @@ machine. If no namespace is provided, the latest definition "wins" and
|
|
|
535
540
|
overrides previous definitions. Nonetheless, a warning is issued:
|
|
536
541
|
`SimpleMultipleExample: overriding method 'run'!`.
|
|
537
542
|
|
|
538
|
-
Alternatively, you can provide a namespace for each state machine
|
|
543
|
+
Alternatively, you can provide a namespace for each state machine. When a namespace
|
|
544
|
+
is used, event methods are defined with the namespace as a suffix, preventing
|
|
545
|
+
collisions between state machines that share event names:
|
|
539
546
|
|
|
540
547
|
```ruby
|
|
541
548
|
class NamespacedMultipleExample
|
|
@@ -1500,7 +1507,7 @@ Feel free to
|
|
|
1500
1507
|
|
|
1501
1508
|
This software is provided "as is" and without any express or
|
|
1502
1509
|
implied warranties, including, without limitation, the implied
|
|
1503
|
-
warranties of
|
|
1510
|
+
warranties of merchantability and fitness for a particular
|
|
1504
1511
|
purpose.
|
|
1505
1512
|
|
|
1506
1513
|
## License ##
|
data/lib/aasm/base.rb
CHANGED
|
@@ -24,7 +24,7 @@ module AASM
|
|
|
24
24
|
configure :skip_validation_on_save, false
|
|
25
25
|
|
|
26
26
|
# raise if the model is invalid (in ActiveRecord)
|
|
27
|
-
configure :whiny_persistence,
|
|
27
|
+
configure :whiny_persistence, true
|
|
28
28
|
|
|
29
29
|
# Use transactions (in ActiveRecord)
|
|
30
30
|
configure :use_transactions, true
|
|
@@ -114,32 +114,28 @@ module AASM
|
|
|
114
114
|
aasm_name = @name.to_sym
|
|
115
115
|
event = name.to_sym
|
|
116
116
|
|
|
117
|
+
# Compute method name with namespace (mirrors how states work on line 98)
|
|
118
|
+
method_name = namespace? ? "#{name}_#{namespace}" : name
|
|
119
|
+
|
|
117
120
|
# an addition over standard aasm so that, before firing an event, you can ask
|
|
118
121
|
# may_event? and get back a boolean that tells you whether the guard method
|
|
119
122
|
# on the transition will let this happen.
|
|
120
|
-
safely_define_method klass, "may_#{
|
|
123
|
+
safely_define_method klass, "may_#{method_name}?", ->(*args) do
|
|
121
124
|
aasm(aasm_name).may_fire_event?(event, *args)
|
|
122
125
|
end
|
|
123
126
|
|
|
124
|
-
safely_define_method klass, "#{
|
|
127
|
+
safely_define_method klass, "#{method_name}!", ->(*args, &block) do
|
|
125
128
|
aasm(aasm_name).current_event = :"#{name}!"
|
|
126
129
|
aasm_fire_event(aasm_name, event, {:persist => true}, *args, &block)
|
|
127
130
|
end
|
|
128
131
|
|
|
129
|
-
safely_define_method klass,
|
|
132
|
+
safely_define_method klass, method_name, ->(*args, &block) do
|
|
130
133
|
aasm(aasm_name).current_event = event
|
|
131
134
|
aasm_fire_event(aasm_name, event, {:persist => false}, *args, &block)
|
|
132
135
|
end
|
|
133
136
|
|
|
134
137
|
skip_instance_level_validation(event, name, aasm_name, klass)
|
|
135
138
|
|
|
136
|
-
# Create aliases for the event methods. Keep the old names to maintain backwards compatibility.
|
|
137
|
-
if namespace?
|
|
138
|
-
klass.send(:alias_method, "may_#{name}_#{namespace}?", "may_#{name}?")
|
|
139
|
-
klass.send(:alias_method, "#{name}_#{namespace}!", "#{name}!")
|
|
140
|
-
klass.send(:alias_method, "#{name}_#{namespace}", name)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
139
|
end
|
|
144
140
|
|
|
145
141
|
def after_all_transitions(*callbacks, &block)
|
|
@@ -264,7 +260,8 @@ module AASM
|
|
|
264
260
|
def skip_instance_level_validation(event, name, aasm_name, klass)
|
|
265
261
|
# Overrides the skip_validation config for an instance (If skip validation is set to false in original config) and
|
|
266
262
|
# restores it back to the original value after the event is fired.
|
|
267
|
-
|
|
263
|
+
method_name = namespace? ? "#{name}_#{namespace}" : name
|
|
264
|
+
safely_define_method klass, "#{method_name}_without_validation!", ->(*args, &block) do
|
|
268
265
|
original_config = AASM::StateMachineStore.fetch(self.class, true).machine(aasm_name).config.skip_validation_on_save
|
|
269
266
|
begin
|
|
270
267
|
AASM::StateMachineStore.fetch(self.class, true).machine(aasm_name).config.skip_validation_on_save = true unless original_config
|
data/lib/aasm/instance_base.rb
CHANGED
|
@@ -68,9 +68,9 @@ module AASM
|
|
|
68
68
|
# filters the results of events_for_current_state so that only those that
|
|
69
69
|
# are really currently possible (given transition guards) are shown.
|
|
70
70
|
if options[:permitted]
|
|
71
|
-
events.select! { |e| @instance.send("may_#{e.name}?", *args) }
|
|
71
|
+
events.select! { |e| @instance.send("may_#{event_method_name(e.name)}?", *args) }
|
|
72
72
|
else
|
|
73
|
-
events.select! { |e| !@instance.send("may_#{e.name}?", *args) }
|
|
73
|
+
events.select! { |e| !@instance.send("may_#{event_method_name(e.name)}?", *args) }
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -115,13 +115,12 @@ module AASM
|
|
|
115
115
|
|
|
116
116
|
def fire(event_name, *args, &block)
|
|
117
117
|
event_exists?(event_name)
|
|
118
|
-
|
|
119
|
-
@instance.send(event_name, *args, &block)
|
|
118
|
+
@instance.send(event_method_name(event_name), *args, &block)
|
|
120
119
|
end
|
|
121
120
|
|
|
122
121
|
def fire!(event_name, *args, &block)
|
|
123
122
|
event_exists?(event_name, true)
|
|
124
|
-
bang_event_name = "#{event_name}!".to_sym
|
|
123
|
+
bang_event_name = "#{event_method_name(event_name)}!".to_sym
|
|
125
124
|
@instance.send(bang_event_name, *args, &block)
|
|
126
125
|
end
|
|
127
126
|
|
|
@@ -133,6 +132,16 @@ module AASM
|
|
|
133
132
|
|
|
134
133
|
private
|
|
135
134
|
|
|
135
|
+
def event_method_name(event_name)
|
|
136
|
+
config = @instance.class.aasm(@name).state_machine.config
|
|
137
|
+
if config.namespace
|
|
138
|
+
ns = (config.namespace == true) ? @name : config.namespace
|
|
139
|
+
"#{event_name}_#{ns}"
|
|
140
|
+
else
|
|
141
|
+
event_name.to_s
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
136
145
|
def event_exists?(event_name, bang = false)
|
|
137
146
|
event = @instance.class.aasm(@name).state_machine.events[event_name.to_sym]
|
|
138
147
|
return true if event
|
data/lib/aasm/localizer.rb
CHANGED
|
@@ -41,18 +41,9 @@ module AASM
|
|
|
41
41
|
|
|
42
42
|
module ClassMethods
|
|
43
43
|
def aasm_create_scope(state_machine_name, scope_name)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
scope scope_name, lambda { where(table_name => conditions) }
|
|
48
|
-
end
|
|
49
|
-
else
|
|
50
|
-
conditions = {
|
|
51
|
-
table_name => { aasm(state_machine_name).attribute_name => scope_name.to_s }
|
|
52
|
-
}
|
|
53
|
-
class_eval do
|
|
54
|
-
named_scope scope_name, :conditions => conditions
|
|
55
|
-
end
|
|
44
|
+
conditions = { aasm(state_machine_name).attribute_name => scope_name.to_s }
|
|
45
|
+
class_eval do
|
|
46
|
+
scope scope_name, lambda { where(table_name => conditions) }
|
|
56
47
|
end
|
|
57
48
|
end
|
|
58
49
|
end
|
data/lib/aasm/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aasm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thorsten Boettger
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-07-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: concurrent-ruby
|
|
@@ -187,6 +187,7 @@ licenses:
|
|
|
187
187
|
- MIT
|
|
188
188
|
metadata:
|
|
189
189
|
changelog_uri: https://github.com/aasm/aasm/blob/master/CHANGELOG.md
|
|
190
|
+
rubygems_mfa_required: 'true'
|
|
190
191
|
post_install_message:
|
|
191
192
|
rdoc_options: []
|
|
192
193
|
require_paths:
|
|
@@ -195,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
195
196
|
requirements:
|
|
196
197
|
- - ">="
|
|
197
198
|
- !ruby/object:Gem::Version
|
|
198
|
-
version:
|
|
199
|
+
version: '3'
|
|
199
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
201
|
requirements:
|
|
201
202
|
- - ">="
|