class Stall::ProductFilters::CategoryFilter
Public Instance Methods
available?()
click to toggle source
# File lib/stall/product_filters/category_filter.rb, line 4 def available? options[:force] || collection.count > 1 end
collection()
click to toggle source
# 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
param()
click to toggle source
# File lib/stall/product_filters/category_filter.rb, line 14 def param :"#{ param_with_parents }_in" end
Private Instance Methods
param_with_parents()
click to toggle source
# File lib/stall/product_filters/category_filter.rb, line 20 def param_with_parents ProductCategory.max_depth.times.map do |index| parents_string = index.times.map { 'parent' }.join('_').presence ['product_category', parents_string, 'id'].compact.join('_') end.join('_or_') end