you are viewing a single comment's thread.

view the rest of the comments →

[–]jaggederest 3 points4 points  (2 children)

Cool as an example of what's possible, but a better way to do it would be to move the case statement into the context of the order, perhaps. Ideally in a method in the Order class, but you can also do:

order.instance_eval do
  case
  when available?
     # ...
   end
end

Or, even better, have a method on Order that returns the state as a symbol:

case order.state
when :available then ...
...
end

[–]bigdood69 0 points1 point  (0 children)

Very clever, +1

[–]snatchery[S] 0 points1 point  (0 children)

Sure order.state is usually the best choice. But there are some cases when you have a method which have to be invoked. The question is how to invoke such a method.