Module: Workarea::Search::Storefront::Product::Inventory
- Included in:
- Workarea::Search::Storefront::Product
- Defined in:
- app/models/workarea/search/storefront/product/inventory.rb
Instance Method Summary collapse
- #displayable_when_out_of_stock? ⇒ Boolean
- #inventory ⇒ Object
- #inventory_score ⇒ Object
- #skus_with_displayable_inventory ⇒ Object
Instance Method Details
#displayable_when_out_of_stock? ⇒ Boolean
27 28 29 |
# File 'app/models/workarea/search/storefront/product/inventory.rb', line 27 def displayable_when_out_of_stock? inventory.records.any?(&:displayable_when_out_of_stock?) end |
#inventory ⇒ Object
6 7 8 |
# File 'app/models/workarea/search/storefront/product/inventory.rb', line 6 def inventory @inventory ||= Workarea::Inventory::Collection.new(skus) end |
#inventory_score ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/models/workarea/search/storefront/product/inventory.rb', line 19 def inventory_score if inventory.available_to_sell.zero? && displayable_when_out_of_stock? 0 else 1 end end |
#skus_with_displayable_inventory ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/models/workarea/search/storefront/product/inventory.rb', line 10 def skus_with_displayable_inventory @skus_with_displayable_inventory ||= if skus.present? inventory.select(&:displayable?).map(&:id) else [] end end |