This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
aasm /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
CHANGELOG | ||
| |
MIT-LICENSE | Wed Oct 14 20:07:46 -0700 2009 | |
| |
README.rdoc | ||
| |
Rakefile | Thu May 29 13:27:44 -0700 2008 | |
| |
TODO | ||
| |
aasm.gemspec | ||
| |
aasm.rb | Mon Jan 07 11:11:38 -0800 2008 | |
| |
doc/ | ||
| |
lib/ | ||
| |
spec/ |
README.rdoc
AASM - Ruby state machines
This package contains AASM, a library for adding finite state machines to Ruby classes.
AASM started as the acts_as_state_machine plugin but has evolved into a more generic library that no longer targets only ActiveRecord models.
AASM has the following features:
- States
- enter - exit - Machines
- Events
- name - success -> callback - transitions block - Transitions
- from - to - on_transition -> callback - guard (returns true or false) - Callbacks
- aasm_before_all_transition -> callback before transition begins - aasm_after_all_transition -> callback after transition ends - default and specific log features
- aasm_log_transition -> instance variable that determines whether to log or not. Defaults to true - aasm_log_method -> the method name for common logging name. Defaults to: aasm_log_transition - aasm_<event_name>_log -> if you want to have a specific log for one particular event just implement a method with this naming convention: aasm_<event_name>_log - aasm also provided the event name, from state and to state to the instance by populating there instance variables: self.aasm_event_name, self.aasm_old_state, self.aasm_new_state - transaction if we choose to persist the transition
- By including AASM, you will have access to these instance methods:
- <state_name>? -> check if the model is in that state - aasm_current_state -> returns the current state of model - <event_name>! -> behaves like save! - <event_name> -> behaves like save - <event_name>_not_persist -> doesn't save to database - aasm_events_for_state -> all events that include the passed state in the from transitions - aasm_events_for_current_state -> all events that include the current state in the from transitions - By including AASM, you will have access to these class methods:
- aasm_states_for_select -> returns options for all states defined
Download
The latest AASM can currently be pulled from the git repository on github.
A release and a gem are forthcoming.
Installation
From GitHub hosted gems
% sudo gem sources -a http://gems.github.com # (you only need to do this once) % sudo gem install mumboe-aasm
Building your own gems
% rake gem % sudo gem install pkg/aasm-0.0.2.gem
Simple Example
Here’s a quick example highlighting some of the features.
class Conversation
include AASM
aasm_initial_state :new
aasm_state :new
aasm_state :read
aasm_state :closed
aasm_event :view do
transitions :to => :read, :from => [:new]
end
aasm_event :close do
transitions :to => :closed, :from => [:read, :new]
end
end
Other Stuff
| Author: | Mumboe Development Team, Scott Barron <scott at elitists dot net> |
| License: | Copyright 2009 by Mumboe Copyright 2006, 2007, 2008 by Scott Barron. Released under an MIT-style license. See the LICENSE file included in the distribution. |
Warranty
This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.








