MyClass::Lifecycle.states.keys lists the states.  This list should be 
available at "compile time" so you can stick an assert in a section of 
code that's being run while "compiling" the class.

cheers,
Bryan


dd wrote:
> Thank you for the reply, but I don't need to check the current state. I 
> need to retrieve any state from the set of states of the lifecycle. Some 
> sort of accessor that fails at compile-time unless you type correctly, 
> like a constant indeed.
> 
> On Tue, Oct 20, 2009 at 9:28 AM, Owen <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 
>     Have you tried this?
> 
>        currentstste=article.lifecycle.state_name
> 
>     -Owen
> 
> 
>     On Oct 20, 1:26 am, dd <[email protected]
>     <mailto:[email protected]>> wrote:
>      > When you define:
>      >
>      >      class Article < ActiveRecord::Base
>      >        Status = HoboFields::EnumString.for
>      > (:draft, :approved, :published)
>      >        fields do
>      >          status Status
>      >        end
>      >      end
>      >
>      > You can use the Article::Status::APPROVED instead of the string
>      > 'approved', and you will avoid any possible typo.
>      >
>      > Is there anything like that (i mean constants or accessors) for the
>      > Lifecycle states?
>      >
>      > If you have:
>      >
>      >      state :foo, :default => true
>      >      state :bar
>      >
>      > How can you access the values through a constant? Something like:
>      > Article::State::FOO or Article::Lifecycle::State::FOO.
>      >
>      > I know: I could set the constants manually and use them to define the
>      > states, but that;s not sexy, specially if there are some internal
>      > constants already set, but I don't find them.
>      >
>      > What is the official way to access any defined state string/symbol?
>      >
>      > Thank you
> 
> 
> 
> 
> -- 
> "I have absolutely no sympathy for human beings whatsoever. None. And no 
> matter what kind of problem humans are facing, whether it's natural or 
> man-made, I always hope it gets worse." (George Carlin)
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to