Class: Stall::ProductFilters::BaseFilter
- Inherits:
-
Object
- Object
- Stall::ProductFilters::BaseFilter
show all
- Defined in:
- lib/stall/product_filters/base_filter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(products, options = {}) ⇒ BaseFilter
Returns a new instance of BaseFilter.
6
7
8
9
|
# File 'lib/stall/product_filters/base_filter.rb', line 6
def initialize(products, options = {})
@products = products
@options = options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/stall/product_filters/base_filter.rb', line 4
def options
@options
end
|
#products ⇒ Object
Returns the value of attribute products.
4
5
6
|
# File 'lib/stall/product_filters/base_filter.rb', line 4
def products
@products
end
|
Instance Method Details
#available? ⇒ Boolean
Can be overriden to hide the filter depending on certain conditions, e.g. there’s more than one option so the filter is useful
22
23
24
|
# File 'lib/stall/product_filters/base_filter.rb', line 22
def available?
options[:force] || true
end
|
#key ⇒ Object
38
39
40
|
# File 'lib/stall/product_filters/base_filter.rb', line 38
def key
@key ||= self.class.name.demodulize.underscore
end
|
#label ⇒ Object
15
16
17
|
# File 'lib/stall/product_filters/base_filter.rb', line 15
def label
I18n.t("stall.products.filters.#{ key }")
end
|
#name ⇒ Object
11
12
13
|
# File 'lib/stall/product_filters/base_filter.rb', line 11
def name
key.gsub(/_filter/, '')
end
|
#partial_locals ⇒ Object
34
35
36
|
# File 'lib/stall/product_filters/base_filter.rb', line 34
def partial_locals
{ filter: self }
end
|
#partial_path ⇒ Object
30
31
32
|
# File 'lib/stall/product_filters/base_filter.rb', line 30
def partial_path
"stall/products/filters/#{ key }"
end
|
#rendering_options(options = {}) ⇒ Object
26
27
28
|
# File 'lib/stall/product_filters/base_filter.rb', line 26
def rendering_options(options = {})
{ partial: partial_path, locals: partial_locals }.deep_merge(options)
end
|