workflow 2.0.1 → 2.0.2
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/README.markdown +4 -5
- data/lib/workflow.rb +0 -1
- data/lib/workflow/version.rb +1 -1
- metadata +10 -13
- data/lib/workflow/adapters/active_record.rb +0 -71
- data/lib/workflow/adapters/remodel.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4834f20238e73dbf0304747da6f098612e395c92a6b839908c7c0a613ad272b8
|
4
|
+
data.tar.gz: 40a8fa57362ed445be012847fe283db2b417225ea3db4ea4c02bcad957630b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb4cd4a9738529cdffc867d04716dbe0bce0df361e84fe55570563624441728e41d2bfec5639cbae6e64dbcf86f047abd73adb542140cb0ecdf92f92be39237
|
7
|
+
data.tar.gz: 1cbbddb5014d83e9ace2b03e2d5e60cf01acbc8f1579d942b68267d144b3513f01fb23797219450e44aca85ae476e4675d57e97fcb149043be16d951c17608c1
|
data/README.markdown
CHANGED
@@ -415,11 +415,6 @@ logging then you can use the universal `on_transition` hook:
|
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
418
|
-
Please also have a look at the [advanced end to end
|
419
|
-
example][advanced_hooks_and_validation_test].
|
420
|
-
|
421
|
-
[advanced_hooks_and_validation_test]: http://github.com/geekq/workflow/blob/master/test/advanced_hooks_and_validation_test.rb
|
422
|
-
|
423
418
|
### on_error
|
424
419
|
|
425
420
|
If you want to do custom exception handling internal to workflow, you can define an `on_error` hook in your workflow.
|
@@ -503,6 +498,10 @@ Development Setup
|
|
503
498
|
Changelog
|
504
499
|
---------
|
505
500
|
|
501
|
+
### New in the version 2.0.2
|
502
|
+
|
503
|
+
* finalize extraction of persistence adapters, remove remodel adapter
|
504
|
+
|
506
505
|
### New in the version 2.0.1
|
507
506
|
|
508
507
|
* retire Ruby 2.3 since it has reached end of live
|
data/lib/workflow.rb
CHANGED
data/lib/workflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dobriakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -95,13 +95,13 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.2'
|
97
97
|
description: |
|
98
|
-
Workflow is a finite-state-machine-inspired API for modeling and
|
99
|
-
|
98
|
+
Workflow is a finite-state-machine-inspired API for modeling and
|
99
|
+
interacting with what we tend to refer to as 'workflow'.
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
* nice DSL to describe your states, events and transitions
|
102
|
+
* various hooks for single transitions, entering state etc.
|
103
|
+
* convenient access to the workflow specification: list states, possible events
|
104
|
+
for particular state
|
105
105
|
email:
|
106
106
|
- vladimir@geekq.net
|
107
107
|
executables: []
|
@@ -111,8 +111,6 @@ extra_rdoc_files:
|
|
111
111
|
files:
|
112
112
|
- README.markdown
|
113
113
|
- lib/workflow.rb
|
114
|
-
- lib/workflow/adapters/active_record.rb
|
115
|
-
- lib/workflow/adapters/remodel.rb
|
116
114
|
- lib/workflow/draw.rb
|
117
115
|
- lib/workflow/errors.rb
|
118
116
|
- lib/workflow/event.rb
|
@@ -120,7 +118,7 @@ files:
|
|
120
118
|
- lib/workflow/specification.rb
|
121
119
|
- lib/workflow/state.rb
|
122
120
|
- lib/workflow/version.rb
|
123
|
-
homepage:
|
121
|
+
homepage: https://github.com/geekq/workflow
|
124
122
|
licenses:
|
125
123
|
- MIT
|
126
124
|
metadata: {}
|
@@ -139,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
137
|
- !ruby/object:Gem::Version
|
140
138
|
version: '0'
|
141
139
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.7.6
|
140
|
+
rubygems_version: 3.0.1
|
144
141
|
signing_key:
|
145
142
|
specification_version: 4
|
146
143
|
summary: A replacement for acts_as_state_machine.
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module Workflow
|
2
|
-
module Adapter
|
3
|
-
module ActiveRecord
|
4
|
-
def self.included(klass)
|
5
|
-
klass.send :include, Adapter::ActiveRecord::InstanceMethods
|
6
|
-
klass.send :extend, Adapter::ActiveRecord::Scopes
|
7
|
-
klass.before_validation :write_initial_state
|
8
|
-
end
|
9
|
-
|
10
|
-
module InstanceMethods
|
11
|
-
def load_workflow_state
|
12
|
-
read_attribute(self.class.workflow_column)
|
13
|
-
end
|
14
|
-
|
15
|
-
# On transition the new workflow state is immediately saved in the
|
16
|
-
# database.
|
17
|
-
def persist_workflow_state(new_value)
|
18
|
-
# Rails 3.1 or newer
|
19
|
-
update_column self.class.workflow_column, new_value
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
# Motivation: even if NULL is stored in the workflow_state database column,
|
25
|
-
# the current_state is correctly recognized in the Ruby code. The problem
|
26
|
-
# arises when you want to SELECT records filtering by the value of initial
|
27
|
-
# state. That's why it is important to save the string with the name of the
|
28
|
-
# initial state in all the new records.
|
29
|
-
def write_initial_state
|
30
|
-
write_attribute self.class.workflow_column, current_state.to_s
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# This module will automatically generate ActiveRecord scopes based on workflow states.
|
35
|
-
# The name of each generated scope will be something like `with_<state_name>_state`
|
36
|
-
#
|
37
|
-
# Examples:
|
38
|
-
#
|
39
|
-
# Article.with_pending_state # => ActiveRecord::Relation
|
40
|
-
# Payment.without_refunded_state # => ActiveRecord::Relation
|
41
|
-
#`
|
42
|
-
# Example above just adds `where(:state_column_name => 'pending')` or
|
43
|
-
# `where.not(:state_column_name => 'pending')` to AR query and returns
|
44
|
-
# ActiveRecord::Relation.
|
45
|
-
module Scopes
|
46
|
-
def self.extended(object)
|
47
|
-
class << object
|
48
|
-
alias_method :workflow_without_scopes, :workflow unless method_defined?(:workflow_without_scopes)
|
49
|
-
alias_method :workflow, :workflow_with_scopes
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def workflow_with_scopes(&specification)
|
54
|
-
workflow_without_scopes(&specification)
|
55
|
-
states = workflow_spec.states.values
|
56
|
-
|
57
|
-
states.each do |state|
|
58
|
-
define_singleton_method("with_#{state}_state") do
|
59
|
-
where("#{table_name}.#{self.workflow_column.to_sym} = ?", state.to_s)
|
60
|
-
end
|
61
|
-
|
62
|
-
define_singleton_method("without_#{state}_state") do
|
63
|
-
where.not("#{table_name}.#{self.workflow_column.to_sym} = ?", state.to_s)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Workflow
|
2
|
-
module Adapter
|
3
|
-
module Remodel
|
4
|
-
module InstanceMethods
|
5
|
-
def load_workflow_state
|
6
|
-
send(self.class.workflow_column)
|
7
|
-
end
|
8
|
-
|
9
|
-
def persist_workflow_state(new_value)
|
10
|
-
update(self.class.workflow_column => new_value)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|