Class: Stall::ProductFilters::Builder
- Inherits:
-
Object
- Object
- Stall::ProductFilters::Builder
- Defined in:
- lib/stall/product_filters/builder.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
Instance Method Summary collapse
- #category_filter ⇒ Object
- #filters ⇒ Object
-
#initialize(products, options = {}) ⇒ Builder
constructor
A new instance of Builder.
- #manufacturer_filter ⇒ Object
- #price_filter ⇒ Object
- #properties_filters ⇒ Object
Constructor Details
#initialize(products, options = {}) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 |
# File 'lib/stall/product_filters/builder.rb', line 6 def initialize(products, = {}) @products = products @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/stall/product_filters/builder.rb', line 4 def @options end |
#products ⇒ Object (readonly)
Returns the value of attribute products.
4 5 6 |
# File 'lib/stall/product_filters/builder.rb', line 4 def products @products end |
Instance Method Details
#category_filter ⇒ Object
15 16 17 |
# File 'lib/stall/product_filters/builder.rb', line 15 def category_filter CategoryFilter.new(products, (:category)) if enabled?(:category) end |
#filters ⇒ Object
11 12 13 |
# File 'lib/stall/product_filters/builder.rb', line 11 def filters [category_filter, manufacturer_filter, price_filter] + properties_filters end |
#manufacturer_filter ⇒ Object
19 20 21 |
# File 'lib/stall/product_filters/builder.rb', line 19 def manufacturer_filter ManufacturerFilter.new(products, (:manufacturer)) if enabled?(:manufacturer) end |
#price_filter ⇒ Object
23 24 25 |
# File 'lib/stall/product_filters/builder.rb', line 23 def price_filter PriceFilter.new(products, (:price)) if enabled?(:price) end |
#properties_filters ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stall/product_filters/builder.rb', line 27 def properties_filters if enabled?(:property) properties.map do |property| = (:property, property: property) PropertyFilter.new(products, ) end else [] end end |