aasm 4.5.1 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/README.md +809 -129
- data/lib/aasm/aasm.rb +74 -37
- data/lib/aasm/base.rb +188 -41
- data/lib/aasm/configuration.rb +27 -2
- data/lib/aasm/core/event.rb +75 -47
- data/lib/aasm/core/invoker.rb +129 -0
- data/lib/aasm/core/invokers/base_invoker.rb +75 -0
- data/lib/aasm/core/invokers/class_invoker.rb +52 -0
- data/lib/aasm/core/invokers/literal_invoker.rb +49 -0
- data/lib/aasm/core/invokers/proc_invoker.rb +59 -0
- data/lib/aasm/core/state.rb +22 -13
- data/lib/aasm/core/transition.rb +30 -23
- data/lib/aasm/dsl_helper.rb +24 -22
- data/lib/aasm/errors.rb +8 -5
- data/lib/aasm/instance_base.rb +63 -15
- data/lib/aasm/localizer.rb +13 -3
- data/lib/aasm/minitest/allow_event.rb +13 -0
- data/lib/aasm/minitest/allow_transition_to.rb +13 -0
- data/lib/aasm/minitest/have_state.rb +13 -0
- data/lib/aasm/minitest/transition_from.rb +21 -0
- data/lib/aasm/minitest.rb +5 -0
- data/lib/aasm/minitest_spec.rb +15 -0
- data/lib/aasm/persistence/active_record_persistence.rb +87 -79
- data/lib/aasm/persistence/base.rb +30 -30
- data/lib/aasm/persistence/core_data_query_persistence.rb +94 -0
- data/lib/aasm/persistence/dynamoid_persistence.rb +92 -0
- data/lib/aasm/persistence/mongoid_persistence.rb +49 -35
- data/lib/aasm/persistence/no_brainer_persistence.rb +105 -0
- data/lib/aasm/persistence/orm.rb +154 -0
- data/lib/aasm/persistence/plain_persistence.rb +2 -1
- data/lib/aasm/persistence/redis_persistence.rb +112 -0
- data/lib/aasm/persistence/sequel_persistence.rb +37 -67
- data/lib/aasm/persistence.rb +20 -5
- data/lib/aasm/rspec/allow_event.rb +5 -1
- data/lib/aasm/rspec/allow_transition_to.rb +5 -1
- data/lib/aasm/rspec/transition_from.rb +8 -4
- data/lib/aasm/state_machine.rb +6 -12
- data/lib/aasm/state_machine_store.rb +76 -0
- data/lib/aasm/version.rb +1 -1
- data/lib/aasm.rb +8 -2
- data/lib/generators/aasm/aasm_generator.rb +16 -0
- data/lib/generators/aasm/orm_helpers.rb +41 -0
- data/lib/generators/active_record/aasm_generator.rb +40 -0
- data/lib/generators/active_record/templates/migration.rb +8 -0
- data/lib/generators/active_record/templates/migration_existing.rb +5 -0
- data/lib/generators/mongoid/aasm_generator.rb +28 -0
- data/lib/generators/nobrainer/aasm_generator.rb +28 -0
- data/lib/motion-aasm.rb +37 -0
- metadata +104 -259
- data/.document +0 -6
- data/.gitignore +0 -19
- data/.travis.yml +0 -37
- data/API +0 -34
- data/CHANGELOG.md +0 -272
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -15
- data/HOWTO +0 -12
- data/PLANNED_CHANGES.md +0 -11
- data/README_FROM_VERSION_3_TO_4.md +0 -240
- data/Rakefile +0 -26
- data/aasm.gemspec +0 -31
- data/callbacks.txt +0 -51
- data/gemfiles/rails_3.2.gemfile +0 -14
- data/gemfiles/rails_4.0.gemfile +0 -12
- data/gemfiles/rails_4.0_mongo_mapper.gemfile +0 -14
- data/gemfiles/rails_4.1.gemfile +0 -12
- data/gemfiles/rails_4.1_mongo_mapper.gemfile +0 -14
- data/gemfiles/rails_4.2.gemfile +0 -12
- data/gemfiles/rails_4.2_mongo_mapper.gemfile +0 -14
- data/gemfiles/rails_4.2_mongoid_5.gemfile +0 -12
- data/lib/aasm/persistence/mongo_mapper_persistence.rb +0 -157
- data/spec/database.rb +0 -63
- data/spec/database.yml +0 -3
- data/spec/en.yml +0 -9
- data/spec/en_deprecated_style.yml +0 -10
- data/spec/models/active_record/basic_active_record_two_state_machines_example.rb +0 -25
- data/spec/models/active_record/complex_active_record_example.rb +0 -33
- data/spec/models/active_record/derivate_new_dsl.rb +0 -7
- data/spec/models/active_record/false_state.rb +0 -35
- data/spec/models/active_record/gate.rb +0 -39
- data/spec/models/active_record/localizer_test_model.rb +0 -34
- data/spec/models/active_record/no_direct_assignment.rb +0 -21
- data/spec/models/active_record/no_scope.rb +0 -21
- data/spec/models/active_record/persisted_state.rb +0 -12
- data/spec/models/active_record/provided_and_persisted_state.rb +0 -24
- data/spec/models/active_record/reader.rb +0 -7
- data/spec/models/active_record/readme_job.rb +0 -21
- data/spec/models/active_record/simple_new_dsl.rb +0 -17
- data/spec/models/active_record/thief.rb +0 -29
- data/spec/models/active_record/transient.rb +0 -6
- data/spec/models/active_record/with_enum.rb +0 -39
- data/spec/models/active_record/with_false_enum.rb +0 -31
- data/spec/models/active_record/with_true_enum.rb +0 -39
- data/spec/models/active_record/writer.rb +0 -6
- data/spec/models/basic_two_state_machines_example.rb +0 -25
- data/spec/models/callbacks/basic.rb +0 -78
- data/spec/models/callbacks/basic_multiple.rb +0 -75
- data/spec/models/callbacks/guard_within_block.rb +0 -66
- data/spec/models/callbacks/guard_within_block_multiple.rb +0 -66
- data/spec/models/callbacks/multiple_transitions_transition_guard.rb +0 -65
- data/spec/models/callbacks/multiple_transitions_transition_guard_multiple.rb +0 -65
- data/spec/models/callbacks/private_method.rb +0 -44
- data/spec/models/callbacks/private_method_multiple.rb +0 -44
- data/spec/models/callbacks/with_args.rb +0 -61
- data/spec/models/callbacks/with_args_multiple.rb +0 -61
- data/spec/models/callbacks/with_state_arg.rb +0 -26
- data/spec/models/callbacks/with_state_arg_multiple.rb +0 -26
- data/spec/models/complex_example.rb +0 -222
- data/spec/models/conversation.rb +0 -93
- data/spec/models/default_state.rb +0 -12
- data/spec/models/double_definer.rb +0 -21
- data/spec/models/foo.rb +0 -92
- data/spec/models/foo_callback_multiple.rb +0 -45
- data/spec/models/guardian.rb +0 -48
- data/spec/models/guardian_multiple.rb +0 -48
- data/spec/models/initial_state_proc.rb +0 -31
- data/spec/models/invalid_persistor.rb +0 -31
- data/spec/models/mongo_mapper/complex_mongo_mapper_example.rb +0 -37
- data/spec/models/mongo_mapper/no_scope_mongo_mapper.rb +0 -21
- data/spec/models/mongo_mapper/simple_mongo_mapper.rb +0 -23
- data/spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb +0 -25
- data/spec/models/mongoid/complex_mongoid_example.rb +0 -37
- data/spec/models/mongoid/no_scope_mongoid.rb +0 -21
- data/spec/models/mongoid/simple_mongoid.rb +0 -23
- data/spec/models/mongoid/simple_new_dsl_mongoid.rb +0 -25
- data/spec/models/no_initial_state.rb +0 -25
- data/spec/models/not_auto_loaded/process.rb +0 -21
- data/spec/models/parametrised_event.rb +0 -29
- data/spec/models/parametrised_event_multiple.rb +0 -29
- data/spec/models/process_with_new_dsl.rb +0 -31
- data/spec/models/provided_state.rb +0 -24
- data/spec/models/sequel/complex_sequel_example.rb +0 -45
- data/spec/models/sequel/sequel_multiple.rb +0 -25
- data/spec/models/sequel/sequel_simple.rb +0 -25
- data/spec/models/silencer.rb +0 -27
- data/spec/models/simple_example.rb +0 -15
- data/spec/models/simple_multiple_example.rb +0 -30
- data/spec/models/state_machine_with_failed_event.rb +0 -12
- data/spec/models/sub_class.rb +0 -7
- data/spec/models/sub_class_with_more_states.rb +0 -18
- data/spec/models/sub_classing.rb +0 -3
- data/spec/models/super_class.rb +0 -46
- data/spec/models/this_name_better_not_be_in_use.rb +0 -11
- data/spec/models/transactor.rb +0 -53
- data/spec/models/valid_state_name.rb +0 -23
- data/spec/models/validator.rb +0 -79
- data/spec/models/worker.rb +0 -2
- data/spec/spec_helper.rb +0 -25
- data/spec/unit/api_spec.rb +0 -77
- data/spec/unit/basic_two_state_machines_example_spec.rb +0 -10
- data/spec/unit/callback_multiple_spec.rb +0 -295
- data/spec/unit/callbacks_spec.rb +0 -296
- data/spec/unit/complex_example_spec.rb +0 -84
- data/spec/unit/complex_multiple_example_spec.rb +0 -99
- data/spec/unit/edge_cases_spec.rb +0 -16
- data/spec/unit/event_multiple_spec.rb +0 -73
- data/spec/unit/event_naming_spec.rb +0 -11
- data/spec/unit/event_spec.rb +0 -322
- data/spec/unit/guard_multiple_spec.rb +0 -60
- data/spec/unit/guard_spec.rb +0 -60
- data/spec/unit/initial_state_multiple_spec.rb +0 -15
- data/spec/unit/initial_state_spec.rb +0 -12
- data/spec/unit/inspection_multiple_spec.rb +0 -201
- data/spec/unit/inspection_spec.rb +0 -111
- data/spec/unit/localizer_spec.rb +0 -76
- data/spec/unit/memory_leak_spec.rb +0 -38
- data/spec/unit/new_dsl_spec.rb +0 -12
- data/spec/unit/persistence/active_record_persistence_multiple_spec.rb +0 -573
- data/spec/unit/persistence/active_record_persistence_spec.rb +0 -552
- data/spec/unit/persistence/mongo_mapper_persistence_multiple_spec.rb +0 -146
- data/spec/unit/persistence/mongo_mapper_persistence_spec.rb +0 -93
- data/spec/unit/persistence/mongoid_persistence_multiple_spec.rb +0 -127
- data/spec/unit/persistence/mongoid_persistence_spec.rb +0 -79
- data/spec/unit/persistence/sequel_persistence_multiple_spec.rb +0 -153
- data/spec/unit/persistence/sequel_persistence_spec.rb +0 -100
- data/spec/unit/readme_spec.rb +0 -42
- data/spec/unit/reloading_spec.rb +0 -15
- data/spec/unit/rspec_matcher_spec.rb +0 -79
- data/spec/unit/simple_example_spec.rb +0 -42
- data/spec/unit/simple_multiple_example_spec.rb +0 -63
- data/spec/unit/state_spec.rb +0 -89
- data/spec/unit/subclassing_multiple_spec.rb +0 -39
- data/spec/unit/subclassing_spec.rb +0 -31
- data/spec/unit/transition_spec.rb +0 -291
data/CHANGELOG.md
DELETED
@@ -1,272 +0,0 @@
|
|
1
|
-
# CHANGELOG
|
2
|
-
|
3
|
-
## 4.5.1
|
4
|
-
|
5
|
-
* make sure to use override configuration options if state machine is defined more than once (see [issue #287](https://github.com/aasm/aasm/issues/287) for details)
|
6
|
-
|
7
|
-
## 4.5.0
|
8
|
-
|
9
|
-
* add RSpec matchers `have_state`, `allow_event` and `allow_transition_to` (see [issue #147](https://github.com/aasm/aasm/issues/147) for details)
|
10
|
-
* add RSpec matcher `transition_from` (see [issue #178](https://github.com/aasm/aasm/issues/178) for details, thanks to [@thomasstephane](https://github.com/thomasstephane))
|
11
|
-
|
12
|
-
## 4.4.1
|
13
|
-
|
14
|
-
* add support for rejecting certain events on inspection (see [issue #272](https://github.com/aasm/aasm/issues/272) for details, thanks to [@dubroe](https://github.com/dubroe))
|
15
|
-
|
16
|
-
## 4.4.0
|
17
|
-
|
18
|
-
* add support global transation callbacks (see [issue #221](https://github.com/aasm/aasm/issues/221) and [issue #253](https://github.com/aasm/aasm/issues/253) for details)
|
19
|
-
* add support (bugfix) for Mongoid >= 5.0 (see [issue #277](https://github.com/aasm/aasm/issues/277) and [issue #278](https://github.com/aasm/aasm/issues/278) for details)
|
20
|
-
|
21
|
-
## 4.3.0
|
22
|
-
|
23
|
-
* add support for multiple state machines per class (see [issue #158](https://github.com/aasm/aasm/issues/158) and [issue #240](https://github.com/aasm/aasm/issues/240) for details)
|
24
|
-
* special thanks to [@evadne](https://github.com/evadne) for testing this feature, and providing comments and patches (see [issue #245](https://github.com/aasm/aasm/issues/245) for details)
|
25
|
-
|
26
|
-
## 4.2.0
|
27
|
-
|
28
|
-
* support turning off and on the configuration option for `no_direct_assignment` (see [issue #223](https://github.com/aasm/aasm/issues/223) for details)
|
29
|
-
* event arguments are now passed to `:after_commit` callbacks as well (see [issue #238](https://github.com/aasm/aasm/pull/238), thanks to [@kuinak](https://github.com/kuinak))
|
30
|
-
|
31
|
-
## 4.1.1
|
32
|
-
|
33
|
-
* support block notation for `:after_commit` event callbacks (see [issue #224](https://github.com/aasm/aasm/issues/224) for details)
|
34
|
-
* event arguments are now passed to state callbacks as well (not only to event callbacks) (see [issue #219](https://github.com/aasm/aasm/issues/219), thanks to [@tobithiel](https://github.com/tobithiel))
|
35
|
-
* `AASM::InvalidTransition` now references the current object (with the state machine) and the _AASM_ event name (see [issue #217](https://github.com/aasm/aasm/issues/217), thanks to [@awsmsrc](https://github.com/awsmsrc))
|
36
|
-
* bugfix: do not update unloaded state for [Sequel](http://sequel.jeremyevans.net/) (see [issue #218](https://github.com/aasm/aasm/issues/218), thanks to [@godfat](https://github.com/godfat))
|
37
|
-
|
38
|
-
## 4.1.0
|
39
|
-
|
40
|
-
* bugfix: initialize the aasm state column after initialization of the _Mongoid_ instance (see [issue #206](https://github.com/aasm/aasm/issues/206), thanks to [@Shwetakale ](https://github.com/Shwetakale ))
|
41
|
-
* added support for mongomapper ORM (see [issue #203](https://github.com/aasm/aasm/issues/203), thanks to [@reidmorrison ](https://github.com/reidmorrison ))
|
42
|
-
* `aasm_column` has been removed. Use `aasm.attribute_name` instead
|
43
|
-
* `aasm_human_event_name` has been removed. Use `aasm.human_event_name` instead
|
44
|
-
|
45
|
-
## 4.0.8
|
46
|
-
|
47
|
-
* bugfix: may_event_name? should return true or false only (see [issue #200](https://github.com/aasm/aasm/issues/200) for details)
|
48
|
-
|
49
|
-
## 4.0.7
|
50
|
-
|
51
|
-
* bugfix: take private methods into account when checking for callbacks (see [issue #197](https://github.com/aasm/aasm/issues/197) for details)
|
52
|
-
|
53
|
-
## 4.0.6
|
54
|
-
|
55
|
-
* bugfix: `false` is treated as uninitialised state (same as `nil`) (see [issue #195](https://github.com/aasm/aasm/issues/195) for details)
|
56
|
-
* bugfix: an event's `:error` callback now retrieves all arguments passed to the event (see [issue #196](https://github.com/aasm/aasm/issues/196) for details)
|
57
|
-
|
58
|
-
## 4.0.5
|
59
|
-
|
60
|
-
* bugfix: initialize the aasm state column after initialization of the _ActiveRecord_ instance only if the attribute has been loaded (see [issue #193](https://github.com/aasm/aasm/issues/193) for details)
|
61
|
-
|
62
|
-
## 4.0.4
|
63
|
-
|
64
|
-
* corrected callback order in README
|
65
|
-
* bugfix: initialize the aasm state column after initialization of the _ActiveRecord_ instance (see [issue #191](https://github.com/aasm/aasm/issues/191) for details)
|
66
|
-
* bugfix: avoid Rails autoloading conflicts (see [issue #137](https://github.com/aasm/aasm/issues/137) and [issue #139](https://github.com/aasm/aasm/issues/139) for details)
|
67
|
-
|
68
|
-
## 4.0.3
|
69
|
-
|
70
|
-
* bugfix: fire guards only once per transition, part 2 (see [issue #187](https://github.com/aasm/aasm/issues/187) for details)
|
71
|
-
* `aasm_column` is deprecated. Use `aasm.attribute_name` instead
|
72
|
-
|
73
|
-
## 4.0.2
|
74
|
-
|
75
|
-
* bugfix: really support block-guards (defined within a transition block) (see [issue #186](https://github.com/aasm/aasm/issues/186) for details)
|
76
|
-
|
77
|
-
## 4.0.1
|
78
|
-
|
79
|
-
* fire guards only once per transition (see [issue #184](https://github.com/aasm/aasm/issues/184) for details)
|
80
|
-
* `aasm_human_event_name` is deprecated, use `aasm.human_event_name` instead
|
81
|
-
|
82
|
-
## 4.0.0
|
83
|
-
|
84
|
-
* support `if` and `unless` guard syntax: (see [issue #179](https://github.com/aasm/aasm/issues/179) and [issue #181](https://github.com/aasm/aasm/issues/181)), thanks to [@bigtunacan](https://github.com/bigtunacan)
|
85
|
-
* may configure to not allow direct assignment for persisted AASM models (see [issue #53](https://github.com/aasm/aasm/issues/53))
|
86
|
-
* **DSL change**: callbacks don't require `to_state` parameter anymore, but still support it
|
87
|
-
(closing issues
|
88
|
-
[#11](https://github.com/aasm/aasm/issues/11),
|
89
|
-
[#58](https://github.com/aasm/aasm/issues/58) and
|
90
|
-
[#80](https://github.com/aasm/aasm/issues/80)
|
91
|
-
thanks to [@ejlangev](https://github.com/ejlangev))
|
92
|
-
* **DSL change**: `after_commit` hooks are now event-based (see [issue #112](https://github.com/aasm/aasm/issues/112))
|
93
|
-
* **DSL change**: event and state callbacks have been re-ordered; state callbacks are not run anymore if any guard fails
|
94
|
-
* **DSL change**: `:on_transition` renamed to `:after`
|
95
|
-
* **DSL change**: `:on_transition` renamed to `:after`
|
96
|
-
* **DSL change**: transition `:after` binding changed (see [issue #59](https://github.com/aasm/aasm/issues/59), thanks to [@stiff](https://github.com/stiff))
|
97
|
-
* **DSL change**: instance-based events inspection now returns event instances (instead of the event names as symbol)
|
98
|
-
* **DSL change**: instance-based permissible_events has been removed in favor or events(:permissible => true)
|
99
|
-
* **DSL change**: class-based events now returns a list of Event instances (instead of a hash with event names as keys)
|
100
|
-
* **DSL change**: renamed permissible states and events to permitted states events
|
101
|
-
* removed deprecated methods (mostly the ones prefixed with `aasm_`)
|
102
|
-
|
103
|
-
## 3.4.0
|
104
|
-
|
105
|
-
* allow retrieving the current event (`aasm.current_event`) (see [issue #159](https://github.com/aasm/aasm/issues/159) and [issue #168](https://github.com/aasm/aasm/issues/168))
|
106
|
-
|
107
|
-
## 3.3.3
|
108
|
-
|
109
|
-
* bugfix: support reloading development environment in Rails (see [issue #148](https://github.com/aasm/aasm/issues/148))
|
110
|
-
|
111
|
-
## 3.3.2
|
112
|
-
|
113
|
-
* bugfix: avoid conflicts with `failed` and `fired` event names (see [issue #157](https://github.com/aasm/aasm/issues/157)), thanks to [@MichaelXavier](https://github.com/MichaelXavier)
|
114
|
-
* bugfix: not using transactions unless saving to the database (see [issue #162](https://github.com/aasm/aasm/issues/162) and [issue #164](https://github.com/aasm/aasm/issues/164)), thanks to [@roberthoner](https://github.com/roberthoner)
|
115
|
-
* bugfix: `after_commit` should only run if saving to the database (see [issue #151](https://github.com/aasm/aasm/issues/151)), thanks to [@ivantsepp](https://github.com/ivantsepp)
|
116
|
-
|
117
|
-
## 3.3.1
|
118
|
-
|
119
|
-
* bugfix: permissible events will respect given `guards` (see [issue #150](https://github.com/aasm/aasm/issues/150))
|
120
|
-
|
121
|
-
## 3.3.0
|
122
|
-
|
123
|
-
* support for Rails 4.1 enum fields (see [issue #124](https://github.com/aasm/aasm/issues/124), thanks to [@bkon](https://github.com/bkon))
|
124
|
-
* bugfix: allow lazy-evaluation for Rails 3 scopes (see [issue #144](https://github.com/aasm/aasm/issues/144), thanks to [@laurens](https://github.com/laurens))
|
125
|
-
|
126
|
-
## 3.2.1
|
127
|
-
|
128
|
-
* bugfix: permissible_events and events did not contain events with an empty "from" transition (see [issue #140](https://github.com/aasm/aasm/issues/140) and [issue #141](https://github.com/aasm/aasm/issues/141), thanks to [@daniel-rikowski](https://github.com/daniel-rikowski))
|
129
|
-
|
130
|
-
## 3.2.0
|
131
|
-
|
132
|
-
* support [Sequel](http://sequel.jeremyevans.net/) (see [issue #119](https://github.com/aasm/aasm/issues/119), thanks to [@godfat](https://github.com/godfat))
|
133
|
-
* may not fire an unknown event (see [issue #128](https://github.com/aasm/aasm/issues/128)
|
134
|
-
|
135
|
-
## 3.1.1
|
136
|
-
|
137
|
-
* bugfix: don't require ActiveRecord for localizing AASM event and state name (see [issue #113](https://github.com/aasm/aasm/issues/113), thanks to [@silentshade](https://github.com/silentshade))
|
138
|
-
|
139
|
-
## 3.1.0
|
140
|
-
|
141
|
-
* validating the current state (see [issue #95](https://github.com/aasm/aasm/issues/95), thanks to [@ivantsepp](https://github.com/ivantsepp))
|
142
|
-
* allow configuring behavior of nested transactions (see [issue #107](https://github.com/aasm/aasm/issues/107))
|
143
|
-
* support multiple guards per transition
|
144
|
-
* support event guards (see [issue #85](https://github.com/aasm/aasm/issues/85))
|
145
|
-
* support reading from- and to-state during on_transition callback (see [issue #100](https://github.com/aasm/aasm/issues/100))
|
146
|
-
|
147
|
-
## 3.0.26
|
148
|
-
|
149
|
-
* support state.human_name (aliased to state.localized_name) (see [issue #105](https://github.com/aasm/aasm/issues/105))
|
150
|
-
|
151
|
-
## 3.0.25
|
152
|
-
|
153
|
-
* initialize the state even if validation is skipped (for ActiveRecord and Mongoid persistence) (see [issue #103](https://github.com/aasm/aasm/issues/103), thanks to [@vfonic](https://github.com/vfonic) and [@aaronklaassen](https://github.com/aaronklaassen))
|
154
|
-
|
155
|
-
## 3.0.24
|
156
|
-
|
157
|
-
* added support for event blocks (thanks to [@Intrepidd](https://github.com/Intrepidd))
|
158
|
-
|
159
|
-
## 3.0.23
|
160
|
-
|
161
|
-
* added support for `after_commit` callback (transaction support) (thanks to [@tisba](https://github.com/tisba))
|
162
|
-
|
163
|
-
## 3.0.22
|
164
|
-
|
165
|
-
* fixed [issue 88](https://github.com/aasm/aasm/issues/88): wrong number of arguments for transaction method
|
166
|
-
|
167
|
-
## 3.0.21
|
168
|
-
|
169
|
-
* support nested ActiveRecord transactions ([@ozeias](https://github.com/ozeias))
|
170
|
-
* allow overwriting of events, can be very useful with inheritance ([@Intrepidd](https://github.com/Intrepidd))
|
171
|
-
|
172
|
-
## 3.0.20
|
173
|
-
|
174
|
-
* added configuration option to disable automatic scope creation
|
175
|
-
|
176
|
-
## 3.0.19
|
177
|
-
|
178
|
-
* fixed deprecation warning with *Rails 4* (`Relation#update_all` with conditions is deprecated)
|
179
|
-
* fixing [issue #69](https://github.com/aasm/aasm/issues/69) ( *ActiveRecord* scopes are not chainable)
|
180
|
-
|
181
|
-
## 3.0.18
|
182
|
-
|
183
|
-
* fixing [issue #66](https://github.com/aasm/aasm/issues/66) (state methods not reflecting the current state)
|
184
|
-
|
185
|
-
## 3.0.17
|
186
|
-
|
187
|
-
* supporting instance level inspection for states (including permissible state, see [issue #54](https://github.com/aasm/aasm/issues/54))
|
188
|
-
* added autocreation of constants for each state ([@jherdman](https://github.com/jherdman))
|
189
|
-
|
190
|
-
## 3.0.16
|
191
|
-
|
192
|
-
* added autocreation of state scopes for Mongoid (thanks to [@jonnyshields](https://github.com/johnnyshields))
|
193
|
-
|
194
|
-
## 3.0.15
|
195
|
-
|
196
|
-
* added support for localized state names (on a class level, like `Record.aasm.states.map(&:localized_name)`)
|
197
|
-
|
198
|
-
## 3.0.14
|
199
|
-
|
200
|
-
* supporting event inspection for to-states transitions (`Event#transitions_to_state?`)
|
201
|
-
|
202
|
-
## 3.0.13
|
203
|
-
|
204
|
-
* supporting *ActiveRecord* transactions when firing an event
|
205
|
-
|
206
|
-
## 3.0.12
|
207
|
-
|
208
|
-
* `aasm_from_states_for_state` now supports to filter for specific transition
|
209
|
-
|
210
|
-
## 3.0.11
|
211
|
-
|
212
|
-
* added class method `aasm_from_states_for_state` to retrieve all from states (regarding transitions) for a given state
|
213
|
-
|
214
|
-
## 3.0.10
|
215
|
-
|
216
|
-
* added support for transitions from all other states (thanks to [@swrobel](https://github.com/swrobel))
|
217
|
-
|
218
|
-
## 3.0.9
|
219
|
-
|
220
|
-
* guard checks (e.g. `may_edit?`) now support guard parameters as well
|
221
|
-
|
222
|
-
## 3.0.8
|
223
|
-
|
224
|
-
* fixed issue with generating docs using yard
|
225
|
-
|
226
|
-
## 3.0.7
|
227
|
-
|
228
|
-
* removed deprecation warning when localizing aasm state names (look at [issue #38](https://github.com/rubyist/aasm/issues/38) for details)
|
229
|
-
|
230
|
-
## 3.0.6
|
231
|
-
|
232
|
-
* bugfix: if configured to skip validation the code does not validate anymore
|
233
|
-
|
234
|
-
## 3.0.5
|
235
|
-
|
236
|
-
* bugfix: get rid of error with old rubygems versions
|
237
|
-
|
238
|
-
## 3.0.4
|
239
|
-
|
240
|
-
* bugfix: Subclasses of aasm-enabled classes don't lose settings anymore (thanks to codez)
|
241
|
-
|
242
|
-
## 3.0.3
|
243
|
-
|
244
|
-
* bugfix: ActiveRecord scopes are generated when using the new DSL
|
245
|
-
|
246
|
-
## 3.0.2
|
247
|
-
|
248
|
-
* ActiveRecord persistence can ignore validation when trying to save invalid models
|
249
|
-
|
250
|
-
## 3.0.1
|
251
|
-
|
252
|
-
* added support for Mongoid (Thanks, Michał Taberski)
|
253
|
-
|
254
|
-
## 3.0.0
|
255
|
-
|
256
|
-
* switched documentation to the new DSL
|
257
|
-
* whiny transactions: by default, raise an exception if an event transition is not possible
|
258
|
-
* you may disable whiny transactions
|
259
|
-
|
260
|
-
## 2.4.0
|
261
|
-
|
262
|
-
* supporting new DSL (which is much shorter)
|
263
|
-
|
264
|
-
## 2.3.1
|
265
|
-
|
266
|
-
* bugfix: avoid naming conflict with i18n
|
267
|
-
|
268
|
-
## 2.3.0
|
269
|
-
|
270
|
-
* supporting i18n
|
271
|
-
* supporting regular expressions for hash values and strings
|
272
|
-
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "sqlite3", :platforms => :ruby
|
4
|
-
gem 'rubysl', :platforms => :rbx
|
5
|
-
gem "jruby-openssl", :platforms => :jruby
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
7
|
-
gem "rails", "~>4.2"
|
8
|
-
gem 'mongoid', '~>4.0' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
|
9
|
-
gem 'sequel'
|
10
|
-
# Since mongoid V4 requires incompatible bson V2, cannot have mongoid (V4 or greater)
|
11
|
-
# and mongo_mapper ( or mongo ) in the same application
|
12
|
-
# gem 'mongo_mapper', '~> 0.13'
|
13
|
-
# gem 'bson_ext', :platforms => :ruby
|
14
|
-
|
15
|
-
gemspec
|
data/HOWTO
DELETED
data/PLANNED_CHANGES.md
DELETED
@@ -1,240 +0,0 @@
|
|
1
|
-
# Migrating from _AASM_ version 3 to 4
|
2
|
-
|
3
|
-
## Must
|
4
|
-
|
5
|
-
### Callback order has been changed
|
6
|
-
|
7
|
-
The first callback to be run is `:before` of the event. A state's `:before_exit` callback
|
8
|
-
is now run directly before its `:exit` callback. Event-based guards are now run before
|
9
|
-
any of the transition guards are run. And finally, before running any state callbacks,
|
10
|
-
all (event- and transition-based) guards are run to check whether the state callbacks
|
11
|
-
can be run or not.
|
12
|
-
|
13
|
-
|
14
|
-
### Callback `:on_transition` renamed to `:after` and changed its binding
|
15
|
-
|
16
|
-
The transition callback `:on_transition` has been renamed to `:after` in order
|
17
|
-
to make clear it is being called (namely _after_ doing the transition).
|
18
|
-
|
19
|
-
Furthermore, in alignment with the other callbacks, it's not receiving the object
|
20
|
-
at hand as first parameter and binds the current object to self.
|
21
|
-
|
22
|
-
In summary, change from
|
23
|
-
|
24
|
-
```ruby
|
25
|
-
aasm do
|
26
|
-
...
|
27
|
-
transitions :from => :from_state, :to => :to_state, :on_transition => :do_something
|
28
|
-
...
|
29
|
-
end
|
30
|
-
|
31
|
-
...
|
32
|
-
def some_other_method(arg)
|
33
|
-
...
|
34
|
-
end
|
35
|
-
|
36
|
-
def do_something(obj, arg1, arg2)
|
37
|
-
obj.some_other_method(arg1)
|
38
|
-
end
|
39
|
-
```
|
40
|
-
|
41
|
-
to
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
aasm do
|
45
|
-
...
|
46
|
-
transitions :from => :from_state, :to => :to_state, :after => :do_something
|
47
|
-
...
|
48
|
-
end
|
49
|
-
|
50
|
-
...
|
51
|
-
def some_other_method(arg)
|
52
|
-
...
|
53
|
-
end
|
54
|
-
|
55
|
-
def do_something(arg1, arg2)
|
56
|
-
some_other_method(arg1) # run on the object as self
|
57
|
-
end
|
58
|
-
```
|
59
|
-
|
60
|
-
|
61
|
-
### `after_commit` hooks are now event-based
|
62
|
-
|
63
|
-
The `after_commit` hooks have been move from the state level to the event level.
|
64
|
-
So, if you want some code block to be executed after the _AASM_ state has been
|
65
|
-
saved **AND** committed, change this code
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
class Job < ActiveRecord::Base
|
69
|
-
include AASM
|
70
|
-
|
71
|
-
aasm do
|
72
|
-
state :sleeping, :initial => true
|
73
|
-
state :running, :after_commit => :notify_about_running_job
|
74
|
-
|
75
|
-
event :run do
|
76
|
-
transitions :from => :sleeping, :to => :running
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def notify_about_running_job
|
81
|
-
...
|
82
|
-
end
|
83
|
-
end
|
84
|
-
```
|
85
|
-
|
86
|
-
to
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
class Job < ActiveRecord::Base
|
90
|
-
include AASM
|
91
|
-
|
92
|
-
aasm do
|
93
|
-
state :sleeping, :initial => true
|
94
|
-
state :running
|
95
|
-
|
96
|
-
event :run, :after_commit => :notify_about_running_job do
|
97
|
-
transitions :from => :sleeping, :to => :running
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def notify_about_running_job
|
102
|
-
...
|
103
|
-
end
|
104
|
-
end
|
105
|
-
```
|
106
|
-
|
107
|
-
|
108
|
-
### Instance-level inspection
|
109
|
-
|
110
|
-
Listing events for the current state now returns Event objects instead of event names (as symbols). So, change from
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
job = Job.new
|
114
|
-
|
115
|
-
job.aasm.events
|
116
|
-
# => [:run]
|
117
|
-
```
|
118
|
-
|
119
|
-
to
|
120
|
-
|
121
|
-
```ruby
|
122
|
-
job = Job.new
|
123
|
-
|
124
|
-
job.aasm.events.map(&:name)
|
125
|
-
# => [:run]
|
126
|
-
```
|
127
|
-
|
128
|
-
Retrieving the list of permitted events has now been integrated into the `events` method. Change from
|
129
|
-
|
130
|
-
```ruby
|
131
|
-
job = Job.new
|
132
|
-
|
133
|
-
job.aasm.permissible_events
|
134
|
-
# => [:run]
|
135
|
-
```
|
136
|
-
|
137
|
-
to
|
138
|
-
|
139
|
-
```ruby
|
140
|
-
job = Job.new
|
141
|
-
|
142
|
-
job.aasm.events(:permitted => true).map(&:name)
|
143
|
-
# => [:run]
|
144
|
-
```
|
145
|
-
|
146
|
-
Class-based events now return a list of `Event` instances. Change from
|
147
|
-
|
148
|
-
```ruby
|
149
|
-
Job.aasm.events.values.map(&:name)
|
150
|
-
# => [:run]
|
151
|
-
```
|
152
|
-
|
153
|
-
to
|
154
|
-
|
155
|
-
```ruby
|
156
|
-
Job.aasm.events.map(&:name)
|
157
|
-
# => [:run]
|
158
|
-
```
|
159
|
-
|
160
|
-
|
161
|
-
## Could
|
162
|
-
|
163
|
-
### Triggering an event without _to_state_
|
164
|
-
|
165
|
-
When providing parameters to callbacks it is not required to provide the `to_state`
|
166
|
-
anymore. So, assuming you have the following class:
|
167
|
-
|
168
|
-
```ruby
|
169
|
-
class Job
|
170
|
-
include AASM
|
171
|
-
|
172
|
-
aasm do
|
173
|
-
state :sleeping, :initial => true
|
174
|
-
state :running
|
175
|
-
|
176
|
-
event :run do
|
177
|
-
transitions :from => :sleeping, :to => :running, :after => :log
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def log(message)
|
182
|
-
logger.info message
|
183
|
-
end
|
184
|
-
end
|
185
|
-
```
|
186
|
-
|
187
|
-
then you could change from
|
188
|
-
|
189
|
-
```ruby
|
190
|
-
job = Job.new
|
191
|
-
job.run(:running, "we want to run")
|
192
|
-
```
|
193
|
-
|
194
|
-
to this:
|
195
|
-
|
196
|
-
```ruby
|
197
|
-
job = Job.new
|
198
|
-
job.run("we want to run")
|
199
|
-
|
200
|
-
job.run(:running, "we want to run") # still supported to select the target state (the _to_state_)
|
201
|
-
```
|
202
|
-
|
203
|
-
On the other hand, you have to accept the arguments for **all** callback methods (and procs)
|
204
|
-
you provide and use. If you don't want to provide these, you can splat them
|
205
|
-
|
206
|
-
```ruby
|
207
|
-
def before(*args); end
|
208
|
-
# or
|
209
|
-
def before(*_); end # to indicate that you don't want to use the arguments
|
210
|
-
```
|
211
|
-
|
212
|
-
### New configuration option: `no_direct_assignment`
|
213
|
-
|
214
|
-
If you want to make sure that the _AASM_ column for storing the state is not directly assigned,
|
215
|
-
configure _AASM_ to not allow direct assignment, like this:
|
216
|
-
|
217
|
-
```ruby
|
218
|
-
class Job < ActiveRecord::Base
|
219
|
-
include AASM
|
220
|
-
|
221
|
-
aasm :no_direct_assignment => true do
|
222
|
-
state :sleeping, :initial => true
|
223
|
-
state :running
|
224
|
-
|
225
|
-
event :run do
|
226
|
-
transitions :from => :sleeping, :to => :running
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
```
|
232
|
-
|
233
|
-
resulting in this:
|
234
|
-
|
235
|
-
```ruby
|
236
|
-
job = Job.create
|
237
|
-
job.aasm_state # => 'sleeping'
|
238
|
-
job.aasm_state = :running # => raises AASM::NoDirectAssignmentError
|
239
|
-
job.aasm_state # => 'sleeping'
|
240
|
-
```
|
data/Rakefile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
|
3
|
-
require 'rspec/core'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'rake/testtask'
|
10
|
-
Rake::TestTask.new(:test) do |test|
|
11
|
-
test.libs << 'lib' << 'test'
|
12
|
-
test.pattern = 'test/**/*_test.rb'
|
13
|
-
test.verbose = true
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'rdoc/task'
|
17
|
-
require 'aasm/version'
|
18
|
-
|
19
|
-
Rake::RDocTask.new do |rdoc|
|
20
|
-
rdoc.rdoc_dir = 'rdoc'
|
21
|
-
rdoc.title = "aasm #{AASM::VERSION}"
|
22
|
-
rdoc.rdoc_files.include('README*')
|
23
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
|
-
end
|
25
|
-
|
26
|
-
task :default => :spec
|
data/aasm.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "aasm/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "aasm"
|
7
|
-
s.version = AASM::VERSION
|
8
|
-
s.authors = ["Scott Barron", "Travis Tilley", "Thorsten Boettger"]
|
9
|
-
s.email = %q{scott@elitists.net, ttilley@gmail.com, aasm@mt7.de}
|
10
|
-
s.homepage = %q{https://github.com/aasm/aasm}
|
11
|
-
s.summary = %q{State machine mixin for Ruby objects}
|
12
|
-
s.description = %q{AASM is a continuation of the acts-as-state-machine rails plugin, built for plain Ruby objects.}
|
13
|
-
s.date = Time.now
|
14
|
-
s.licenses = ["MIT"]
|
15
|
-
|
16
|
-
s.platform = Gem::Platform::RUBY
|
17
|
-
s.required_ruby_version = '>= 1.9.3'
|
18
|
-
|
19
|
-
s.add_development_dependency 'rake'
|
20
|
-
s.add_development_dependency 'sdoc'
|
21
|
-
s.add_development_dependency 'rspec', ">= 3"
|
22
|
-
|
23
|
-
# debugging
|
24
|
-
# s.add_development_dependency 'debugger'
|
25
|
-
s.add_development_dependency 'pry'
|
26
|
-
|
27
|
-
s.files = `git ls-files`.split("\n")
|
28
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
30
|
-
s.require_paths = ["lib"]
|
31
|
-
end
|
data/callbacks.txt
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
callbacks
|
2
|
-
|
3
|
-
AASM 3
|
4
|
-
|
5
|
-
begin
|
6
|
-
old_state exit # old? should be deprecated -> use old_state.before_exit instead
|
7
|
-
event before
|
8
|
-
old_state before_exit
|
9
|
-
new_state before_enter
|
10
|
-
new_state enter # old? should be deprecated -> use new_state.before_enter instead
|
11
|
-
...update state...
|
12
|
-
transition guard
|
13
|
-
event guard
|
14
|
-
transition on_transition
|
15
|
-
event success # if persist successful
|
16
|
-
old_state after_exit
|
17
|
-
new_state after_enter
|
18
|
-
event after
|
19
|
-
rescue
|
20
|
-
event error
|
21
|
-
end
|
22
|
-
|
23
|
-
AASM 4
|
24
|
-
|
25
|
-
todo
|
26
|
-
|
27
|
-
done
|
28
|
-
- move event.before before everything else
|
29
|
-
- move old_state.before_exit before old_state.exit
|
30
|
-
- move event.guard before transition.guard
|
31
|
-
- fire guards before running state callbacks (test run)
|
32
|
-
|
33
|
-
begin
|
34
|
-
event before
|
35
|
-
event guard # test run
|
36
|
-
transition guard # test run
|
37
|
-
old_state before_exit
|
38
|
-
old_state exit
|
39
|
-
new_state before_enter
|
40
|
-
new_state enter
|
41
|
-
event guard
|
42
|
-
transition guard
|
43
|
-
transition on_transition
|
44
|
-
...update state...
|
45
|
-
event success # if persist successful
|
46
|
-
old_state after_exit
|
47
|
-
new_state after_enter
|
48
|
-
event after
|
49
|
-
rescue
|
50
|
-
event error
|
51
|
-
end
|