Class: Rawbotz::Models::Stock
- Inherits:
-
Object
- Object
- Rawbotz::Models::Stock
- Includes:
- ActiveModel::Model
- Defined in:
- lib/rawbotz/models/stock.rb
Class Method Summary collapse
- .all_stock ⇒ Object
-
.stock_for(product_ids) ⇒ Object
Returns a map of product_id to RawgentoDB::ProductQty .
Class Method Details
.all_stock ⇒ Object
8 9 10 11 12 |
# File 'lib/rawbotz/models/stock.rb', line 8 def self.all_stock stock = {} RawgentoDB::Query.stock.each {|s| stock[s.product_id] = s.qty} stock end |
.stock_for(product_ids) ⇒ Object
Returns a map of product_id to RawgentoDB::ProductQty .
15 16 17 18 19 20 21 22 |
# File 'lib/rawbotz/models/stock.rb', line 15 def self.stock_for product_ids stock = {} # Find ruby idiomatic way to do that (probably map{}.to_h) RawgentoDB::Query.stock_for(product_ids).each do |s| stock[s.product_id] = s.qty end stock end |