Class: PowerShop::Product
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PowerShop::Product
- Defined in:
- app/models/power_shop/product.rb
Direct Known Subclasses
Class Method Summary collapse
-
.active ⇒ Object
Public: get only active products.
Instance Method Summary collapse
- #decrement_category_count ⇒ Object
- #increment_category_count ⇒ Object
-
#main_image ⇒ Object
Public: get first image from images.
- #touch_category_count ⇒ Object
Class Method Details
.active ⇒ Object
Public: get only active products
Returns ActiveRecord::Relation
22 23 24 |
# File 'app/models/power_shop/product.rb', line 22 def self.active where(active: true) end |
Instance Method Details
#decrement_category_count ⇒ Object
37 38 39 |
# File 'app/models/power_shop/product.rb', line 37 def decrement_category_count ::Category.decrement_counter :products_count, category_id end |
#increment_category_count ⇒ Object
33 34 35 |
# File 'app/models/power_shop/product.rb', line 33 def increment_category_count ::Category.increment_counter :products_count, category_id end |
#main_image ⇒ Object
Public: get first image from images
Returns ShopImage
29 30 31 |
# File 'app/models/power_shop/product.rb', line 29 def main_image images.first end |
#touch_category_count ⇒ Object
41 42 43 |
# File 'app/models/power_shop/product.rb', line 41 def touch_category_count active? ? increment_category_count : decrement_category_count end |