Module: Workarea::FeaturedProducts

Extended by:
ActiveSupport::Concern
Included in:
Catalog::Category, Search::Customization
Defined in:
app/models/workarea/featured_products.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.changesets(*product_ids) ⇒ Object



13
14
15
16
17
18
# File 'app/models/workarea/featured_products.rb', line 13

def self.changesets(*product_ids)
  Release::Changeset.any_of(
    { 'changeset.product_ids' => { '$in' => product_ids } },
    { 'original.product_ids' => { '$in' => product_ids } }
  )
end

Instance Method Details

#add_product(id) ⇒ Object



28
29
30
31
# File 'app/models/workarea/featured_products.rb', line 28

def add_product(id)
  product_ids.prepend(id)
  save
end

Returns:

  • (Boolean)


24
25
26
# File 'app/models/workarea/featured_products.rb', line 24

def featured_product?(id)
  id.to_s.in?(product_ids)
end

Returns:

  • (Boolean)


20
21
22
# File 'app/models/workarea/featured_products.rb', line 20

def featured_products?
  product_ids.present?
end

#remove_product(id_to_remove) ⇒ Object



33
34
35
36
# File 'app/models/workarea/featured_products.rb', line 33

def remove_product(id_to_remove)
  product_ids.reject! { |id| id == id_to_remove }
  save
end