class Stall::ProductFilters::BaseFilter

Attributes

options[R]
products[R]

Public Class Methods

new(products, options = {}) click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 6
def initialize(products, options = {})
  @products = products
  @options = options
end

Public Instance Methods

available?() click to toggle source

Can be overriden to hide the filter depending on certain conditions, e.g. there's more than one option so the filter is useful

# File lib/stall/product_filters/base_filter.rb, line 22
def available?
  options[:force] || true
end
key() click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 38
def key
  @key ||= self.class.name.demodulize.underscore
end
label() click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 15
def label
  I18n.t("stall.products.filters.#{ key }")
end
name() click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 11
def name
  key.gsub(/_filter/, '')
end
partial_locals() click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 34
def partial_locals
  { filter: self }
end
partial_path() click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 30
def partial_path
  "stall/products/filters/#{ key }"
end
rendering_options(options = {}) click to toggle source
# File lib/stall/product_filters/base_filter.rb, line 26
def rendering_options(options = {})
  { partial: partial_path, locals: partial_locals }.deep_merge(options)
end