Class: Stockman::Logic::Product::SellablesCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/stockman/logic/product/sellables_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_id) ⇒ SellablesCollection

Returns a new instance of SellablesCollection.



9
10
11
# File 'lib/stockman/logic/product/sellables_collection.rb', line 9

def initialize(product_id)
  @product_id = product_id
end

Instance Attribute Details

#product_idObject (readonly)

Returns the value of attribute product_id.



7
8
9
# File 'lib/stockman/logic/product/sellables_collection.rb', line 7

def product_id
  @product_id
end

Instance Method Details

#eachObject



21
22
23
# File 'lib/stockman/logic/product/sellables_collection.rb', line 21

def each
  sellables.each{ |sellable| yield sellable }
end

#sellablesObject



13
14
15
# File 'lib/stockman/logic/product/sellables_collection.rb', line 13

def sellables
  @sellables ||= load_sellables
end

#stock_levelsObject



17
18
19
# 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