spree/spree-product-assembly — pull request #66 by kianw (2014-02-10 20:21:08+00:00)
Title: Hooks for customizing parts per LineItem

Added `LineItem#parts` and `LineItem#count_of` which call the same method on the LineItem's Product.
All line-item-oriented references to `product.parts` and `product.count_of` converted to use the new
LineItem methods. By overriding these new methods, applications can use custom logic to determine
which parts are actually included in a specific LineItem.

This is very helpful for us, as we had a situation where the product has a sequence of parts, and the user could select to start and end anywhere in the sequence. Without the ability to customize the parts for a specific LineItem, we would have had to create > 50 products, each with a slightly different set of parts, with all the maintenance headaches that entails. Now we just override `LineItem#parts` with a bit of code to adjust the parts list as needed.

All the specs pass. The only problem I foresee with this, is what happens if the overridden logic in `LineItem#parts` changes (or the inputs it relies on change), resulting in changes to its return values over time. I suppose we should really persist the linkage between LineItem and the part Variant, but this is not expected to be an issue in our application (famous last words...).

In any case, this PR only provides a seamless hook, and what you do with it is your own issue.