Sha256: a8c53607d42f6c22065f7fad1a0fe8e11ccfb987a576422ad6eb7b8f8dd9007d
Contents?: true
Size: 715 Bytes
Versions: 2
Compression:
Stored size: 715 Bytes
Contents
module Workarea module Admin class VariantComponentViewModel < ApplicationViewModel delegate :details, to: :product_variant def product @product ||= begin product = options[:product].presence product ||= Catalog::Product.find(product_id) if product_id product ||= Catalog::Product.find_by_sku(sku) if product.is_a?(ProductViewModel) product else ProductViewModel.wrap(product, sku: sku) end end end def name "#{product.name} (#{sku})" end def product_variant @product_variant ||= product.variants.detect { |v| v.sku == sku } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems