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

Wrap Splitter chaining behaviour in new Stock::SplitterChain class #2189

Merged
merged 3 commits into from
Aug 31, 2017

Conversation

jhawthorn
Copy link
Contributor

Previously the Stock::Packer was responsible for building a chain of Stock::Splitter objects to split objects after packaging. This required some precise behaviour (like order of initialization) as well as edgecase handling (empty array of splitters) which wasn't well tested and should be outside the responsibilities of the Packer itself.

This extracts the behaviour to Spree::Stock::SplitterChain, which handles building and calling the splitters.

This also changes the first argument to Splitter::Base#initialize from a Stock::Packer to a Spree::StockLocation (with a deprecation notice).

These attributes were already declared on the superclass
class SplitterChain
attr_reader :stock_location

def initialize(stock_location, splitter_classes=[])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surrounding space missing in default value assignment.

Previously the Stock::Packer was responsible for building a chain of
Splitter objects to split objects after packaging. This required some
precise behaviour (like order of initialization) as well as edgecase
handling (empty array of splitters) which wasn't well tested and should
be outside the responsibilities of the Packer itself.

This extracts the behaviour to Spree::Stock::SplitterChain, which
handles building and calling the splitters.
Previously, Splitters were tightly coupled to Stock::Packer without good
reason. None of the Splitters in core use this, and I don't expect it to
be used or needed in custom splitters.

This commit replaces the first argument of Splitter::Base#initialize
with StockLocation. Passing a Packer will work, but print a deprecation
warning.
Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As always, excellent work. Thank you John!

@jhawthorn jhawthorn merged commit 292e7ac into solidusio:master Aug 31, 2017
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.

3 participants