Writing more unit tests for this as we speak

Thanks for the tip Robert

PS - I presume, if I were to use constants that I would define the
constants in the class itself?

On 12 Feb, 15:17, Robert Walker <[email protected]>
wrote:
> Gavin wrote:
> > So, would it be more appropriate to write a method like
>
> > def purchased?
> >   if self.status > 3
> >     return true
> >   else
> >     return false
> >   end
> > end
>
> > and then call the purchased? method to perform the check?
>
> > On 12 Feb, 14:39, Robert Walker <[email protected]>
>
> Actually it could be as simple as adding some constants to represent
> your states.
>
> Example:
> STARTED = 1
> PROCESSING = 2
> COMPLETED = 3
> BILLED = 4
> PAID = 5
>
> if self.state > COMPLETED
>
> You just want to avoid the use of a "magic number" by giving it clear
> meaning.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to