Sha256: 30ad1e544a224bde0e950dabbaaaa1f611b0729943f61cd28eddb82c807faf7d

Contents?: true

Size: 597 Bytes

Versions: 5

Compression:

Stored size: 597 Bytes

Contents

module Workarea
  decorate Storefront::ProductViewModel::ImageCollection, with: :browse_option do

    def primary
      @browse_option_primary ||= browse_option_image || super
    end

    private

    def browse_option_image
      unless @product.browses_by_option? && current_browse_option.present?
        return
      end

      @all.detect do |image|
        image.option&.optionize.in?(
          Array(current_browse_option).map(&:optionize)
        )
      end
    end

    def current_browse_option
      @options[:option] || @options[@product.browse_option.optionize]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 app/view_models/workarea/storefront/product_view_model/image_collection.decorator
workarea-browse_option-2.1.9 app/view_models/workarea/storefront/product_view_model/image_collection.decorator
workarea-browse_option-2.1.8 app/view_models/workarea/storefront/product_view_model/image_collection.decorator
workarea-browse_option-2.1.7 app/view_models/workarea/storefront/product_view_model/image_collection.decorator
workarea-browse_option-2.1.6 app/view_models/workarea/storefront/product_view_model/image_collection.decorator