state_machines 0.304.0 → 0.306.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4e9546f230db48a9895e84f10f8f8ea71bb5934864adc72fa97a466af5e3af3
|
|
4
|
+
data.tar.gz: 163c6d689b435eb01bf137de5c866db39fe1f9061bd5fa77f05d3e019cf450cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65fa1768e9543d26d65993624230fb8e7ac5040073ca7df7ed561613152856b796271a42fb7cd31e7c0165ea2a8b2bc336788bbcdbdf8aa7e64295975df1ddb9
|
|
7
|
+
data.tar.gz: 53a3fd1ad1de916e997502cca89537a239d7a7e93461938bab9a85860bb2803b81187ca8c006cfe23d724088d036240955595e59d1d774c9554ab3833854f055
|
|
@@ -80,6 +80,16 @@ module StateMachines
|
|
|
80
80
|
check_conflicting_attribute_default
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
# Whether a state predicate's conflict with a method the owner class
|
|
84
|
+
# already defines is expected, such as a Rails enum's. Returning true
|
|
85
|
+
# only silences the warning: the predicate is still not defined.
|
|
86
|
+
#
|
|
87
|
+
# @param _method [String] the predicate's name, such as "parked?"
|
|
88
|
+
# @return [Boolean]
|
|
89
|
+
def ignore_method_conflict?(_method)
|
|
90
|
+
false
|
|
91
|
+
end
|
|
92
|
+
|
|
83
93
|
private
|
|
84
94
|
|
|
85
95
|
# Gets the default messages that can be used in the machine for invalid
|
|
@@ -395,6 +395,10 @@ module StateMachines
|
|
|
395
395
|
# understand this and what the consequences are, setting the
|
|
396
396
|
# +ignore_method_conflicts+ option is a perfectly reasonable workaround.
|
|
397
397
|
#
|
|
398
|
+
# An integration can silence only the predicate conflicts it expects by
|
|
399
|
+
# overriding +ignore_method_conflict?+. Those predicates are still not
|
|
400
|
+
# defined.
|
|
401
|
+
#
|
|
398
402
|
# == Integrations
|
|
399
403
|
#
|
|
400
404
|
# By default, state machines are library-agnostic, meaning that they work
|
data/lib/state_machines/state.rb
CHANGED
|
@@ -341,7 +341,7 @@ module StateMachines
|
|
|
341
341
|
end
|
|
342
342
|
|
|
343
343
|
def warn_about_method_conflict(method, defined_in)
|
|
344
|
-
return if StateMachines::Machine.ignore_method_conflicts
|
|
344
|
+
return if StateMachines::Machine.ignore_method_conflicts || machine.send(:ignore_method_conflict?, method)
|
|
345
345
|
|
|
346
346
|
warn machine.send(:method_conflict_message, :instance, method, defined_in)
|
|
347
347
|
end
|
|
@@ -261,6 +261,22 @@ module StateMachines
|
|
|
261
261
|
@persisted = true
|
|
262
262
|
end
|
|
263
263
|
|
|
264
|
+
# Whether this transition's state change is in place: written by {#persist}
|
|
265
|
+
# and not undone since by {#rollback} (or {#reset}).
|
|
266
|
+
#
|
|
267
|
+
# A transition that is refused never stays persisted: a halting before
|
|
268
|
+
# callback stops it ahead of the write, and a failed or raising action
|
|
269
|
+
# rolls it back. Once the action has succeeded nothing rolls it back, so
|
|
270
|
+
# it stays persisted whatever the after phase does (an after callback
|
|
271
|
+
# halting, an around callback halting or raising after its yield). A
|
|
272
|
+
# successful preview (e.g. ActiveRecord's +valid?+) leaves it persisted
|
|
273
|
+
# for the full run that completes it.
|
|
274
|
+
#
|
|
275
|
+
# @return [Boolean]
|
|
276
|
+
def persisted?
|
|
277
|
+
@persisted == true
|
|
278
|
+
end
|
|
279
|
+
|
|
264
280
|
# Rolls back changes made to the object's state via this transition. This
|
|
265
281
|
# will revert the state back to the +from+ value.
|
|
266
282
|
#
|