Class: Item::Materials::CompatibleInsulations

Inherits:
BaseCompatibleFinder
  • Object
show all
Defined in:
app/services/item/materials/compatible_insulations.rb

Overview

This class is responsible for finding a catalog item's compatible insulations

Instance Method Summary collapse

Instance Method Details

#get_product_line(item) ⇒ Object



25
26
27
28
# File 'app/services/item/materials/compatible_insulations.rb', line 25

def get_product_line(item)
  return unless item.is_heating_element? && item.is_floor_heating_product?
  item.primary_product_line&.get_first_heating_system_type
end

#process(item:, catalog_items_scope: nil) ⇒ Object

At a minimum you need an item
If you provide a catalog item scope, such as Catalog.catalog_items.for_online_catalog
It will be used to populate the catalog_items results
Without a catalog item scope only the items will be populated in the result



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/item/materials/compatible_insulations.rb', line 8

def process(item:, catalog_items_scope: nil)
  items = Item.none
  catalog_items = CatalogItem.none
  messages = []

  if pl = get_product_line(item)
    if pl.slug_ltree.to_s.include?('tempzone') || pl.slug_ltree.to_s.include?('environ')
      items = Item.active
                  .by_product_line_path(LtreePaths::PL_FLOOR_HEATING_UNDERLAYMENT_THERMALSHEET)
                  .by_product_category_path(LtreePaths::PC_ACCESSORIES_INSULATIONS)
    end
  end

  return_results(item: item, items: items, catalog_items_scope: catalog_items_scope)

end