class Stockman::Logic::Product::StockLevelsCollection
Attributes
product_id[R]
Public Class Methods
new(product_id)
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 9 def initialize(product_id) @product_id = product_id.to_i end
Public Instance Methods
[](warehouse_id)
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 33 def [](warehouse_id) find_by_warehouse(warehouse_id) end
each() { |stock_level| ... }
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 25 def each stock_levels.each{ |stock_level| yield stock_level } end
empty?()
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 29 def empty? stock_levels.empty? end
find_by_warehouse(warehouse_id)
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 37 def find_by_warehouse(warehouse_id) stock_levels.detect{ |stock_level| stock_level.warehouse_id == warehouse_id } end
sellables()
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 13 def sellables @sellables ||= SellablesCollection.new(product_id) end
stock_levels()
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 17 def stock_levels @stock_levels ||= load_stock_levels end
warehouse_ids()
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 21 def warehouse_ids @warehouse_ids ||= load_warehouse_ids end
Private Instance Methods
load_stock_levels()
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 47 def load_stock_levels warehouse_ids.inject([]) do |memo, warehouse_id| memo << StockLevel.new(sellables, warehouse_id) end end
load_warehouse_ids()
click to toggle source
# File lib/stockman/logic/product/stock_levels_collection.rb, line 43 def load_warehouse_ids sellables.map(&:warehouse_ids).flatten.uniq end