Class: Workarea::ProductReleases

Inherits:
Object
  • Object
show all
Defined in:
app/queries/workarea/product_releases.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#productObject (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

#changesetsMongoid::Criteria

All Releasables that could affect the product’s Elasticsearch document should add their changesets to this method.

Examples:

Add to the changesets affecting a product in a decorator

def changesets
  super.merge(SomeReleasable.for_product(product.id).changesets_with_children)
end

Returns:



23
24
25
26
27
28
# File 'app/queries/workarea/product_releases.rb', line 23

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_skusObject



30
31
32
# File 'app/queries/workarea/product_releases.rb', line 30

def pricing_skus
  Pricing::Sku.in(id: product.skus).to_a
end

#releasesObject



9
10
11
# File 'app/queries/workarea/product_releases.rb', line 9

def releases
  Release.schedule_affected_by_changesets(changesets)
end