Class: Workarea::ProductReleases
- Inherits:
-
Object
- Object
- Workarea::ProductReleases
- Defined in:
- app/queries/workarea/product_releases.rb
Instance Attribute Summary collapse
-
#product ⇒ Object
readonly
Returns the value of attribute product.
Instance Method Summary collapse
-
#changesets ⇒ Mongoid::Criteria
All Releasables that could affect the product’s Elasticsearch document should add their changesets to this method.
-
#initialize(product) ⇒ ProductReleases
constructor
A new instance of ProductReleases.
- #pricing_skus ⇒ Object
- #releases ⇒ Object
Constructor Details
#initialize(product) ⇒ ProductReleases
Returns a new instance of ProductReleases.
5 6 7 |
# File 'app/queries/workarea/product_releases.rb', line 5 def initialize(product) @product = product end |
Instance Attribute Details
#product ⇒ Object (readonly)
Returns the value of attribute product.
3 4 5 |
# File 'app/queries/workarea/product_releases.rb', line 3 def product @product end |
Instance Method Details
#changesets ⇒ Mongoid::Criteria
All Releasables that could affect the product’s Elasticsearch document should add their changesets to this method.
27 28 29 30 31 32 |
# File 'app/queries/workarea/product_releases.rb', line 27 def changesets criteria = product.changesets_with_children pricing_skus.each { |ps| criteria.merge!(ps.changesets_with_children) } criteria.merge!(FeaturedProducts.changesets(product.id)) criteria.includes(:release) end |
#pricing_skus ⇒ Object
34 35 36 |
# File 'app/queries/workarea/product_releases.rb', line 34 def pricing_skus Pricing::Sku.in(id: product.skus).to_a end |
#releases ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/queries/workarea/product_releases.rb', line 9 def releases changesets .uniq(&:release) .reject { |cs| cs.release.blank? } .flat_map { |cs| [cs.release] + cs.release.scheduled_after } .uniq end |