state_machine 0.9.0: Locked and loaded

I‘ve decided the only way to go viral is to get a cat to use state_machine. I’m just having a hard time getting past that whole “cats can’t program” thing… so blogging it is! Last week, state_machine 0.9.0 was tagged after a month’s worth of active development. This is a major milestone that I’m really excited to share with all of you.
If you can dodge a bullet, you can dodge a ball. Wait, what?
If you’ve been following the project for a while, you’ll know that I only bump major versions when there are significant changes in either the public API or the feature set. Fortunately, this release comes loaded with a bunch of new features (and some fixes) that I hope you’ll all enjoy:
- MongoMapper 0.5.5+ integration support
- ActiveModel 3.0.0+ integration support (extracted from ActiveRecord)
- DataMapper 0.10.3+ support
- around_transition callbacks (supplements before/after callbacks)
- Rails 3 railtie integration
- Consolidated rake tasks
- Unified API for event / attribute transitions
- …and 7 bug fixes
To me, the most interesting part of this release has been building support for around_transition callbacks. Here’s a basic example of its usage:
class Vehicle < ActiveRecord::Base state_machine :initial => :parked do around_transition :on => :ignite, :do => :benchmark event :ignite do transition :parked => :first_gear end end def benchmark puts "...starting benchmark" time = Benchmark.measure { yield } puts "...completed in: #{time.real}" end end v = Vehicle.new v.ignite # ...starting benchmark # ...completed in: 0.0642118453979492 v.state # => "idling" v = Vehicle.new(:state_event => 'ignite') v.valid? # ...starting benchmark v.state # => "idling" sleep 1 v.save # ...completed in: 1.00799298286438
See the full list of changes here.
I can only show you the door… unfortunately, it’s locked.
Besides addition of the above features, 0.9.0 is also a significant milestone as it marks the beginning of feature lockdown on state_machine. All future changes will be primarily for maintenance means (fixing bugs, compatibility with releases of integrated ORMs, etc.). This is the final push to get to an official 1.0.0 release.
However, I need your help to get to 1.0.0. If you encounter bugs in any part of the code or see any issues with the documentation, now is the time to report them.
Otherwise, enjoy this release
Feed










