Class: Stall::ProductFilters::CategoryFilter

Inherits:
BaseFilter
  • Object
show all
Defined in:
lib/stall/product_filters/category_filter.rb

Instance Attribute Summary

Attributes inherited from BaseFilter

#options, #products

Instance Method Summary collapse

Methods inherited from BaseFilter

#initialize, #key, #label, #name, #partial_locals, #partial_path, #rendering_options

Constructor Details

This class inherits a constructor from Stall::ProductFilters::BaseFilter

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/stall/product_filters/category_filter.rb', line 4

def available?
  options[:force] || collection.count > 1
end

#collectionObject



8
9
10
11
12
# File 'lib/stall/product_filters/category_filter.rb', line 8

def collection
  @collection ||= ProductCategory.joins(:products)
    .where(stall_products: { id: products.select(:id) })
    .distinct
end

#paramObject



14
15
16
# File 'lib/stall/product_filters/category_filter.rb', line 14

def param
  :"#{ param_with_parents }_in"
end