Module: Workarea::FeaturedProducts

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

Instance Method Summary collapse

Instance Method Details

#add_product(id) ⇒ Object



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

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

Returns:

  • (Boolean)


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

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

Returns:

  • (Boolean)


12
13
14
# File 'app/models/workarea/featured_products.rb', line 12

def featured_products?
  product_ids.present?
end

#remove_product(id_to_remove) ⇒ Object



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

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