in reply to Re^2: Saltine::Toffee
in thread Saltine::Toffee

There's a lot going on that's not obvious at first.

Note that ->contents() can either be passed an ID to return a particular content object from the container, or be passed nothing to return an object representing all contained objects. The Saucepan class has a few convenience methods that automatically generate such an object and do the work on it: $pan->melt is just shorthand for $pan->contents()->melt; same with $pan->bubble.

The Cookie::Sheet class is more generic and doesn't have such methods, since they could cause confusion. Note the $sheet->contents()->state( "cool" ) call; state iterates over each object contained in the object returned by contents() and verifies that they are all "cool". $sheet->state( "cool" ) just checks that the sheet itself is cool; some of it's contents may still be hot.

Another nice thing is the Ingredient class; it's constructor can take a quantity or it can return a lazy object whose quantity is undetermined until it's actually used in a quantized context, e.g. $sheet->spread( Ingredient->new( "crackers", type => "saltine" ),