Class: Workarea::FeaturedCategorization
- Inherits:
-
Object
- Object
- Workarea::FeaturedCategorization
- Includes:
- Enumerable
- Defined in:
- app/queries/workarea/featured_categorization.rb
Instance Method Summary collapse
- #all ⇒ Object
- #categories_affected_by_current_release ⇒ Object
- #category_changesets_affecting_current_release ⇒ Object
-
#initialize(*product_ids) ⇒ FeaturedCategorization
constructor
A new instance of FeaturedCategorization.
- #live ⇒ Object
Constructor Details
#initialize(*product_ids) ⇒ FeaturedCategorization
Returns a new instance of FeaturedCategorization.
6 7 8 |
# File 'app/queries/workarea/featured_categorization.rb', line 6 def initialize(*product_ids) @product_ids = product_ids end |
Instance Method Details
#all ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/queries/workarea/featured_categorization.rb', line 10 def all @all ||= begin result = live categories_affected_by_current_release.each do |category| if product_featured_in_category?(category) result += [category] unless result.include?(category) else result -= [category] end end result end end |
#categories_affected_by_current_release ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/queries/workarea/featured_categorization.rb', line 30 def categories_affected_by_current_release return [] if Release.current.blank? Catalog::Category.in( id: category_changesets_affecting_current_release.map(&:releasable_id) ) end |
#category_changesets_affecting_current_release ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/queries/workarea/featured_categorization.rb', line 38 def category_changesets_affecting_current_release return [] if Release.current.blank? FeaturedProducts .changesets(*@product_ids) .where(releasable_type: Catalog::Category.name) .in(release_id: Release.current.preview.releases.map(&:id)) end |