Skip to content
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

Conversation

jordan-brough
Copy link
Contributor

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.

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 }

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.

@mamhoff
Copy link
Contributor

mamhoff commented Mar 3, 2016

I like this. This would mean that the shipping rates estimation could be part of the to_shipment method on the package class, and I could get rid of the strange attr_accessor in Spree::ShippingRate.

@cbrunsdon
Copy link
Contributor

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.

@jhawthorn
Copy link
Contributor

I wouldn't mind #packages being public, as I could see that being useful, but I don't feel that strongly.

👍

@jordan-brough
Copy link
Contributor Author

Great! I added a changelog entry.

jordan-brough added a commit that referenced this pull request Mar 4, 2016
…-area

Reduce the surface area of Spree::Stock::Coordinator
@jordan-brough
Copy link
Contributor Author

Merged in f8b889a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants