rails-workflow 1.4.11 → 1.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/workflow/adapters/active_record.rb +39 -6
- data/lib/workflow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d215275ad6a4ce79e08310152150012a3cc8ac0
|
4
|
+
data.tar.gz: 970e42fdc6b4d5f4d2cd78a76bcc365847792d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1955fd9145001d3ea4b2dc8bfa8b34e0fb612db028d0d8e24a0ccf01efb51a8a88cc4dd05787ad716419c5d7ec6e20da335031b59ae5cd892aad55bc312f18df
|
7
|
+
data.tar.gz: cf316591ef4198441c6c5b21f5220169d73ceeb68642c5cb8d357427413d8d072d3f5fb136744026177ad26892bc18aabac1de628a3723ebd50863f9cc4aa70a
|
@@ -63,16 +63,49 @@ module Workflow
|
|
63
63
|
workflow_spec.states.each { |state| define_scopes(state) }
|
64
64
|
end
|
65
65
|
|
66
|
+
# Find objects that are in a terminal state - no available
|
67
|
+
# event transitions
|
68
|
+
# @return [ActiveRecord::Relation] ActiveRecord query object meeting the criteria
|
69
|
+
def in_terminal_state
|
70
|
+
with_state workflow_spec.states.select(&:terminal?)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Find objects that are not in a terminal state
|
74
|
+
# @return [ActiveRecord::Relation] ActiveRecord query object meeting the criteria
|
75
|
+
def not_in_terminal_state
|
76
|
+
with_state(workflow_spec.states.reject(&:terminal?))
|
77
|
+
end
|
78
|
+
|
79
|
+
# Locate objects that are in a state tagged with the given tag(s)
|
80
|
+
#
|
81
|
+
# @param [Symbol] tags List of tags that apply
|
82
|
+
# @return [ActiveRecord::Relation] ActiveRecord query object meeting the criteria
|
66
83
|
def state_tagged_with(*tags)
|
67
|
-
|
68
|
-
states.map! { |state| state.name.to_s }
|
69
|
-
where(workflow_state: states)
|
84
|
+
with_state workflow_spec.states.tagged_with(tags)
|
70
85
|
end
|
71
86
|
|
87
|
+
# Locate objects that are not in a state tagged with the given tag(s)
|
88
|
+
#
|
89
|
+
# @param [Symbol] tags List of tags the objects (and their states) should not have
|
90
|
+
# @return [ActiveRecord::Relation] ActiveRecord query object meeting the criteria
|
72
91
|
def state_not_tagged_with(*tags)
|
73
|
-
|
74
|
-
|
75
|
-
|
92
|
+
with_state workflow_spec.states.not_tagged_with(tags)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Find objects in the given state(s)
|
96
|
+
#
|
97
|
+
# @param [Object] states Symbol, String or {Workflow::State} objects
|
98
|
+
# @return [ActiveRecord::Relation] ActiveRecord query object meeting the criteria
|
99
|
+
def with_state(*states)
|
100
|
+
states = [states].flatten
|
101
|
+
states.map! do |state|
|
102
|
+
if state.is_a?(Workflow::State)
|
103
|
+
state.name.to_s
|
104
|
+
else
|
105
|
+
state.to_s
|
106
|
+
end
|
107
|
+
end
|
108
|
+
where(workflow_state: states)
|
76
109
|
end
|
77
110
|
|
78
111
|
private
|
data/lib/workflow/version.rb
CHANGED