Sha256: 10a42307e5b39cc7ba512d839f84aec74179f550960e26148fcc592b53bc75fd
Contents?: true
Size: 760 Bytes
Versions: 2
Compression:
Stored size: 760 Bytes
Contents
module Stockman module Logic class Product class SellablesCollection include Enumerable attr_reader :product_id def initialize(product_id) @product_id = product_id end def sellables @sellables ||= load_sellables end def stock_levels @stock_levels ||= sellables.map(&:stock_levels).flatten.map(&:stock_levels).flatten end def each sellables.each{ |sellable| yield sellable } end private def load_sellables Storage.obtain_set("products:#{product_id}:sellables").map do |sellable_data| SellableFactory.build_sellable(sellable_data) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stockman-logic-0.1.1 | lib/stockman/logic/product/sellables_collection.rb |
stockman-logic-0.1.0 | lib/stockman/logic/product/sellables_collection.rb |