geekq/workflow — pull request #49 by svoop (2012-05-25 10:51:43+00:00)
Title: Make states comparable

With this little patch (README example and tests included), states are comparable on Ruby 1.9 and above. Here's the example from the README:

article.current_state
=> being_reviewed
article.current_state < :accepted
=> true
article.current_state >= :accepted
=> false
article.between? :awaiting_review, :rejected
=> true

This comes in very handy for instance when a certain form element is only shown if the article has at least a certain state. Without comparable states, the necessary ifs become very cumbersome and hard to maintain.

Rubies <1.9 don't get this feature since the corresponding code checks RUBY_VERSION. Support for Ruby 1.8 is doable (by use of some ordered hash e.g. from ActiveSupport or another ordered hash gem), however, Ruby 1.8 is no longer developed and bugfixes will fade out just a few months from now, so IMHO, there's no real need to support utterly outdated Ruby versions.

Hope you like this feature and thanks for consider merging it.