I could see this being useful, but I can also see the problem of name clashes (which are a nightmare to debug). I would bet there's a good reason lifecycles were separated to their own class and guess that it was to avoid some sort of namespace issue.
On Apr 21, 2:05 pm, Henry Baragar <[email protected]> wrote: > Hello, > > For models with lifecycles, I have been doing a lot of: > > do_something if rec.state == "active" > > Then I wanted to change the names of the states and found out that this > practice is very fragile. > > I was starting to add methods of the form "<state>?" when I wondered if > I missed anything in Hobo. All I could find was that methods of the > form "<state>_state?" get added to the lifecycle object. I tried using > this in a few places: > > do_something if rec.lifecycle.active_state? > > and found that this code might be a bit less fragile, but the code is > not as clear as comparing directly to the string. > > I now am of the the opinion that: > > do_something if rec.active? > > is a much better approach and that hobo should automatically define > "<state>?" in the model (and "<transition>!" too). > > In case you are thinking that this pollutes the model name space or > could lead to name clashes, consider the following two points: > > 1. States and transitions, in my experience, are very much in the > core behavior (or reason-being) of the model > 2. Getting these boolean state methods is at least as obvious as > getting a "state" method/field installed when we declare a > lifecycle, and much more obvious than the new "position" > method/field we get when we declare a model to "acts_as_list". > > I am hoping to get some feedback on this suggestion before adding it to > lighthouse. > > Regards, > Henry > > -- > You received this message because you are subscribed to the Google Groups > "Hobo Users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/hobousers?hl=en. -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
