Sha256: 5de10bf8686a6b55ae97af134624dbfbfa2150a8f464f38308c1ba2ff6a47984
Contents?: true
Size: 818 Bytes
Versions: 26
Compression:
Stored size: 818 Bytes
Contents
module Spree module Stock module Splitter class Digital < Spree::Stock::Splitter::Base def split(packages) split_packages = [] packages.each do |package| split_packages += split_by_digital(package) end return_next(split_packages) end private def split_by_digital(package) digitals = Hash.new { |hash, key| hash[key] = [] } package.contents.each do |item| digitals[item.variant.digital?] << item end hash_to_packages(digitals) end def hash_to_packages(digitals) packages = [] digitals.each do |_id, contents| packages << build_package(contents) end packages end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems