class Stockman::Logic::Product::SellablesCollection

Attributes

product_id[R]

Public Class Methods

new(product_id) click to toggle source
# File lib/stockman/logic/product/sellables_collection.rb, line 9
def initialize(product_id)
  @product_id = product_id
end

Public Instance Methods

each() { |sellable| ... } click to toggle source
# File lib/stockman/logic/product/sellables_collection.rb, line 21
def each
  sellables.each{ |sellable| yield sellable }
end
sellables() click to toggle source
# File lib/stockman/logic/product/sellables_collection.rb, line 13
def sellables
  @sellables ||= load_sellables
end
stock_levels() click to toggle source
# File lib/stockman/logic/product/sellables_collection.rb, line 17
def stock_levels
  @stock_levels ||= sellables.map(&:stock_levels).flatten.map(&:stock_levels).flatten
end

Private Instance Methods

load_sellables() click to toggle source
# File lib/stockman/logic/product/sellables_collection.rb, line 27
def load_sellables
  Storage.obtain_set("products:#{product_id}:sellables").map do |sellable_data|
    SellableFactory.build_sellable(sellable_data)
  end
end