rails-workflow 1.4.12 → 1.4.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d215275ad6a4ce79e08310152150012a3cc8ac0
4
- data.tar.gz: 970e42fdc6b4d5f4d2cd78a76bcc365847792d45
3
+ metadata.gz: 30ada397c29addd3b7b628691797ac590f7214d0
4
+ data.tar.gz: 0e7375ee4380363fb96ac04c3f7e3d62608e9ed4
5
5
  SHA512:
6
- metadata.gz: 1955fd9145001d3ea4b2dc8bfa8b34e0fb612db028d0d8e24a0ccf01efb51a8a88cc4dd05787ad716419c5d7ec6e20da335031b59ae5cd892aad55bc312f18df
7
- data.tar.gz: cf316591ef4198441c6c5b21f5220169d73ceeb68642c5cb8d357427413d8d072d3f5fb136744026177ad26892bc18aabac1de628a3723ebd50863f9cc4aa70a
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
- # This module will automatically generate ActiveRecord scopes based on workflow states.
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
- # Examples:
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
- # Payment.without_refunded_state # => ActiveRecord::Relation
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Workflow
3
- VERSION = '1.4.12'
3
+ VERSION = '1.4.13'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.12
4
+ version: 1.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Gannon