Class: Workarea::Search::Storefront::ProductOptionImageUrl

Inherits:
ProductPrimaryImageUrl
  • Object
show all
Defined in:
app/models/workarea/search/storefront/product_option_image_url.rb

Instance Method Summary collapse

Constructor Details

#initialize(product, image_size: :small_thumb, option:) ⇒ ProductOptionImageUrl

Returns a new instance of ProductOptionImageUrl.



5
6
7
8
# File 'app/models/workarea/search/storefront/product_option_image_url.rb', line 5

def initialize(product, image_size: :small_thumb, option:)
  super(product, image_size)
  @option = option
end

Instance Method Details

#imageObject



10
11
12
13
14
# File 'app/models/workarea/search/storefront/product_option_image_url.rb', line 10

def image
  @product.images.find_by(option: @option)
rescue Mongoid::Errors::DocumentNotFound
  super
end