-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce the surface area of Spree::Stock::Coordinator #950
Reduce the surface area of Spree::Stock::Coordinator #950
Conversation
Make 'shipments' the only public method of the Coordinator. It's the only method called on Coordinator outside of the specs. This was prompted by me looking at the Coordinator code while reviewing some of the taxes work and thinking it might be nice to refactor it a bit, which is easier with a reduced surface area.
expect(packages.map(&:quantity).sum).to eq(5) | ||
expect(packages.flat_map(&:contents).map(&:inventory_unit).uniq.size).to eq(5) | ||
expect(shipments).not_to be_empty | ||
inventory_units = shipments.flat_map { |s| s.inventory_units } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass &:inventory_units
as an argument to flat_map
instead of a block.
I like this. This would mean that the shipping rates estimation could be part of the |
I also like this but reckon it will need a changelog if it goes in, as we are technically immediately removing a method from the public API. I have such a poor understanding of what a "package" does I'd rather this be the only thing accessible by a co-ordinator, and agree it would give us more flexibility to (eventually) make some meaningful changes behind the scenes if we can get this in. |
I wouldn't mind 👍 |
Great! I added a changelog entry. |
…-area Reduce the surface area of Spree::Stock::Coordinator
Merged in f8b889a |
Make 'shipments' the only public method of the Coordinator. It's the
only method called on Coordinator outside of the specs.
This was prompted by me looking at the Coordinator code while
reviewing some of the taxes work and thinking it might be nice to
refactor it a bit, which is easier with a reduced surface area.