1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
Commit graph

24 commits

Author SHA1 Message Date
Tim Pope
d59dbbf6b0 Allow duplicate state names in subclasses
When an AASM including class is subclassed, a shallow copy is made of
the StateMachine object.  This means that all subclasses share the same
states hash and thus the same set of states, which prevents (among other
things) different subclasses from using the same state names.

Give StateMachine a smart #clone method that copies the states hash and
invoke that rather than #dup upon subclassing.
2008-11-05 11:06:36 -05:00
Tim Pope
fee9487e0d Invoke original inherited callback when subclassed
When AASM is included into a class, it defines inherited, clobbering
the original definition.  This problem becomes readily apparent with STI
in Rails, where the original method is part of the implementation of
inheritable attributes, a feature relied on for several ActiveRecord
features such as callbacks and timestamp recording.

Move the implementation of inherited to ClassMethods and invoke the
original method via super.
2008-10-09 19:03:00 -04:00
Jon Distad
f44a808636 Added support for lambdas and arrays of method symbols to success callback 2008-10-09 10:53:39 -04:00
Jon Distad
ea29d0960e new aasm unit spec 2008-10-03 13:22:26 -04:00
Jon Distad
f2c5380807 modified (and fixed) failed event! behavior due to failed aasm_write_state() call 2008-10-03 13:15:39 -04:00
Jon Distad
3eb2ea20f2 bang event methods now return false and dont transition on failed save 2008-10-03 11:22:51 -04:00
Scott Barron
cd4f9146aa This spec wasn't really working right. 2008-08-13 17:56:16 -04:00
Scott Barron
3d69497ee3 Take state column for AR persistance out of class variables and add them to the
StateMachine object.
2008-06-22 11:17:12 -04:00
Kevin Triplett
8a7320b9d0 allowed :to array and :on_transition callback, with tests 2008-06-03 23:44:25 -05:00
Scott Barron
216b48e519 Get rid of class vars added to classes including AASM, support inheritance on AASMs 2008-06-01 14:48:17 -07:00
Scott Barron
3ccbeaca88 Support enter and exit actions on states 2008-05-31 15:08:12 -07:00
Scott Barron
30a8d15ef5 Modify State to prep for enter/entering/exit actions 2008-05-31 14:33:07 -07:00
Scott Barron
0ee1ad986f coverage for event fired/failed method when using non-! methods 2008-05-30 16:33:27 -07:00
Scott Barron
61b5327cc8 Fix AR specs and rcov target 2008-05-29 13:23:53 -07:00
Chad Humphries
34444b7632 Corrected aasm_states_for_select to return state as string for option value. 2008-05-29 07:05:50 -07:00
Edgecase Pair One
fc86784602 Added success callback which takes place after persistent aasm writes 2008-05-20 15:27:35 -04:00
Jeff Dean
a0bb1c404c make sure the 2 fields are in sync by using before_validation_on_create 2008-04-29 01:58:05 -04:00
Jeff Dean
cb6bd4f534 * Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
Allowing for nil values in states for active record
  New non-(!) methods that allow for firing events without persisting [Jeff Dean]
2008-04-29 01:27:56 -04:00
Chad Humphries
c196fef669 Re-exposing options on state, for devious extra uses 2008-04-14 19:49:57 -04:00
Chad Humphries
bd788a5212 Added aasm_states_for_select that will return a select friendly collection of states.
Also added additional tests
2008-04-14 15:57:34 -04:00
Scott Barron
61b6b8ec06 Add two event callbacks:
aasm_event_fired(from, to) - called when an event is fired successfully
aasm_event_failed(event)   - called when an event fails

These could be used to implement transition logging [Artem Vasiliev] or
setting a timestamp column [Mike Ferrier] as well as other pieces of love and magic.
2008-03-02 07:52:46 -05:00
Scott Barron
29304c70ae Some specs for #aasm_events_for_current_state 2008-03-02 07:33:37 -05:00
Scott Barron
ea7820db4a More consistent aasm_ namespacing 2008-02-21 12:59:28 -05:00
Scott Barron
7a734376c4 Reorg spec dir to have units and functionals 2008-02-21 12:18:08 -05:00