Module: Spree::ProductDecorator
- Defined in:
- app/models/spree/product_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.prepended(base) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/models/spree/product_decorator.rb', line 3 def self.prepended(base) base.has_many :home_section_products, class_name: 'Spree::HomeSectionProduct' base.has_many :home_sections, through: :home_section_products, class_name: 'Spree::HomeSection' end |
Instance Method Details
#image_url(style: :product) ⇒ Object
12 13 14 15 16 17 |
# File 'app/models/spree/product_decorator.rb', line 12 def image_url(style: :product) image = images.first return if image.blank? image.url(style) end |
#presenter_attributes ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/models/spree/product_decorator.rb', line 19 def presenter_attributes { id: id, name: name, image: image_url(style: :mini) } end |