If the reason you're checking whether $items is defined is because you want it to return the total when it's called without args, then that's not Moose-y.
Store subtotal, prices, and specials in attributes. Have ->scan check whether an item exists in inventory (in this case: whether it has a price, but if you want to pretend there's another way to handle it, using a method for that check allows easy subclassing to override that). Then add the item's price, modulo special rules, to the total. Decide whether to die when encountering a bad item or to just complain loudly to STDERR and ignore the error otherwise -- the latter makes more sense in a cash register setting.
In reply to Re: Refactoring a Moose Class
by Anonymous Monk
in thread Refactoring a Moose Class
by purinkle_2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |