Class: Stall::ProductFilters::PropertyFilter
- Inherits:
-
BaseFilter
- Object
- BaseFilter
- Stall::ProductFilters::PropertyFilter
show all
- Defined in:
- lib/stall/product_filters/property_filter.rb
Instance Attribute Summary collapse
Attributes inherited from BaseFilter
#options, #products
Instance Method Summary
collapse
Methods inherited from BaseFilter
#key, #partial_path, #rendering_options
Constructor Details
Returns a new instance of PropertyFilter.
6
7
8
9
|
# File 'lib/stall/product_filters/property_filter.rb', line 6
def initialize(*)
super
@property = options[:property]
end
|
Instance Attribute Details
#property ⇒ Object
Returns the value of attribute property.
4
5
6
|
# File 'lib/stall/product_filters/property_filter.rb', line 4
def property
@property
end
|
Instance Method Details
#available? ⇒ Boolean
11
12
13
|
# File 'lib/stall/product_filters/property_filter.rb', line 11
def available?
@available ||= (options[:force] || collection.count > 1)
end
|
#collection ⇒ Object
27
28
29
30
31
|
# File 'lib/stall/product_filters/property_filter.rb', line 27
def collection
@collection ||= property.property_values.joins(variants: :product)
.where(stall_products: { id: products.select(:id) })
.distinct
end
|
#label ⇒ Object
19
20
21
|
# File 'lib/stall/product_filters/property_filter.rb', line 19
def label
property.name
end
|
#name ⇒ Object
15
16
17
|
# File 'lib/stall/product_filters/property_filter.rb', line 15
def name
property.name.parameterize
end
|
#param ⇒ Object
23
24
25
|
# File 'lib/stall/product_filters/property_filter.rb', line 23
def param
:variants_property_values_id_in
end
|
#partial_locals ⇒ Object
33
34
35
|
# File 'lib/stall/product_filters/property_filter.rb', line 33
def partial_locals
{ filter: self, property: property }
end
|