From 65ddcfaf381e1fcf95b7e03baf041896b5b7ba4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dakotah=20Pen=CC=83a?= Date: Tue, 19 Jul 2016 16:32:34 -0700 Subject: [PATCH] Added documentation for auto-generated constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a great feature that I’ve researched in the past and found no information before. A colleague finally found a merged PR related to this and it’s a shame it isn’t documented. --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index b85e242..395e864 100644 --- a/README.md +++ b/README.md @@ -418,6 +418,28 @@ SimpleMultipleExample.aasm(:work).states *Final note*: Support for multiple state machines per class is a pretty new feature (since version `4.3`), so please bear with us in case it doesn't work as expected. +### Auto-generated Status Constants + +AASM automatically [generates constants](https://github.com/aasm/aasm/pull/60) +for each status so you don't have to explicitly define them. + +```ruby +class Foo + include AASM + + aasm do + state :initialized + state :calculated + state :finalized + end +end + +> Foo::STATE_INITIALIZED +#=> :initialized +> Foo::STATE_CALCULATED +#=> :calculated +``` + ### Extending AASM AASM allows you to easily extend `AASM::Base` for your own application purposes.