Sha256: 7e57b31dd7f0a93fd2127b4fbf991ceb73220e1516fefcaf57e1ccd1e4313e12
Contents?: true
Size: 616 Bytes
Versions: 11
Compression:
Stored size: 616 Bytes
Contents
# frozen_string_literal: true module Alchemy class EssenceSpreeProduct < ActiveRecord::Base PRODUCT_ID = /\A\d+\z/ belongs_to :product, class_name: 'Spree::Product', optional: true, foreign_key: 'spree_product_id' acts_as_essence(ingredient_column: :product) def ingredient=(product_or_id) case product_or_id when PRODUCT_ID self.spree_product_id = product_or_id when Spree::Product self.product = product_or_id else super end end def preview_text(_maxlength) return unless product product.name end end end
Version data entries
11 entries across 11 versions & 1 rubygems