public
Description: Adds support for creating state machines for attributes on any Ruby class
Homepage: http://www.pluginaweek.org
Clone URL: git://github.com/pluginaweek/state_machine.git

Comments for pluginaweek's state_machine   feed

michelangelo-altamore commented on pluginaweek/state_machine Mon Mar 23 01:24:55 -0700 2009
Comment in 9c8f587:

s/unqalified/unqualified/

raganwald commented on pluginaweek/state_machine Mon Dec 15 21:33:35 -0800 2008
Comment in f056c17:

I think I see what is going on here, there is a special case for initialize such that it does not appear as an instance method, and alias_method does not respect the special case.

I was surprised because I often use define_method to define instance methods. i see now the issue has to do with aliasing.

Thanks!

p.s. Have you seen this alternative to alias_method?

obrie commented on pluginaweek/state_machine Mon Dec 15 17:59:22 -0800 2008
Comment in f056c17:

Also, the reason behind this change is that Rails will spit out warnings when reloading in development mode because it sees “initialize” as an instance method and removes it from the class.

obrie commented on pluginaweek/state_machine Mon Dec 15 17:56:15 -0800 2008
Comment in f056c17:

It’s very subtle, indeed, even though the comment is out of date.

Using class_eval/define_method techniques:


class A
  def initialize
  end
end

A.class_eval do alias_method :initialize_without_something, :initialize define_method(:initialize) do initialize_without_something end end

A.instance_methods.include?(‘initialize’) # => false

Using aliasing:


class A
  def initialize
  end
end

A.class_eval do alias_method :initialize_without_something, :initialize def initialize_with_something end alias_method :initialize, :initialize_with_something end

A.instance_methods.include?(‘initialize’) # => true

That comment was meant as a reminder for why define_method was being used instead of an alias technique.

raganwald commented on pluginaweek/state_machine Mon Dec 15 08:39:09 -0800 2008
Comment in f056c17:

define_method is used to prevent it from showing up in #instance_methods: Perhaps I do not understand what you mean. When I use #define_method in Ruby 1.8.7, the name of the method I define shows up when I call #instance_methods on the class.

Is there some subtlety I am missing here with respect to 1.8.6? Or to calling #define_method in a module? Or something else?

leftist commented on pluginaweek/state_machine Sun Dec 14 18:44:55 -0800 2008
Comment in 48d83df:

Awesome! Looks like a great predicates implementation.

Keep up the good work!

leftist commented on pluginaweek/state_machine Wed Dec 10 00:06:29 -0800 2008
Comment in 6f25124:

This patch is a real nipple rubber. You rule, Nate!

I think I said I was going to do this three days ago. I love GitHub…

tobi commented on pluginaweek/state_machine Tue Sep 30 11:12:22 -0700 2008
Comment in 6a94afc:

Brilliant change. I used this to implement fine gained cache expiry for comments in Shopify and it fit like a glove.