rails-workflow 1.4.12 → 1.4.13
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/lib/workflow/adapters/active_record.rb +17 -5
- data/lib/workflow/specification.rb +10 -0
- 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: 30ada397c29addd3b7b628691797ac590f7214d0
|
4
|
+
data.tar.gz: 0e7375ee4380363fb96ac04c3f7e3d62608e9ed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 349149ca15104eb4a9aef2f48d3090a48434b60e0842f6be06de9bece667c8119d6f0f220e5f28f70f8898d0db70b2a85278108b73d91e9815b8fe1c69932086
|
7
|
+
data.tar.gz: ad54fca54b8276f34badbc4e80c6ff2e72bca982ed501b1cc5b1d9dfeafc283206db9a8eb748ef8d3663cb62d39a415774fe9d6e042323f1ccab732ef9b15ed5
|
@@ -37,14 +37,26 @@ module Workflow
|
|
37
37
|
write_attribute self.class.workflow_column, current_state.name
|
38
38
|
end
|
39
39
|
|
40
|
-
#
|
41
|
-
# The name of each generated scope will be something like `with_<state_name>_state`
|
40
|
+
# Scopes for the ActiveRecord entity class.
|
42
41
|
#
|
43
|
-
#
|
42
|
+
# Two scopes for each {Workflow::State} specified plus some general ones:
|
44
43
|
#
|
44
|
+
# Examples:
|
45
|
+
# ~~~ruby
|
46
|
+
# class Article < ApplicationRecord
|
47
|
+
# include Workflow
|
48
|
+
# state :pending, tags: :some_tag do
|
49
|
+
# on :submit, to: :submitted
|
50
|
+
# end
|
51
|
+
# state :submitted
|
52
|
+
# end
|
45
53
|
# Article.with_pending_state # => ActiveRecord::Relation
|
46
|
-
#
|
47
|
-
#
|
54
|
+
# Article.without_pending_state # => ActiveRecord::Relation
|
55
|
+
# Article.state_tagged_with(:some_tag, :another_tag)
|
56
|
+
# Article.state_not_tagged_with(:some_tag)
|
57
|
+
# Article.in_terminal_state
|
58
|
+
#
|
59
|
+
# ~~~
|
48
60
|
# Example above just adds `where(:state_column_name => 'pending')` or
|
49
61
|
# `where.not(:state_column_name => 'pending')` to AR query and returns
|
50
62
|
# ActiveRecord::Relation.
|
@@ -57,6 +57,16 @@ module Workflow
|
|
57
57
|
states.find { |t| t.name == name.to_sym }
|
58
58
|
end
|
59
59
|
|
60
|
+
# @return [Array] Array of unique event names defined for this workflow spec.
|
61
|
+
def event_names
|
62
|
+
events.map(&:name).uniq
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Array] Names of states defined on this workflow spec.
|
66
|
+
def state_names
|
67
|
+
states.map(&:name)
|
68
|
+
end
|
69
|
+
|
60
70
|
# @api private
|
61
71
|
#
|
62
72
|
# @param [Hash] meta Metadata
|
data/lib/workflow/version.rb
CHANGED