Class: Alchemy::EssenceSpreeProduct

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/alchemy/essence_spree_product.rb

Constant Summary collapse

PRODUCT_ID =
/\A\d+\z/

Instance Method Summary collapse

Instance Method Details

#ingredient=(product_or_id) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'app/models/alchemy/essence_spree_product.rb', line 12

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

#preview_text(_maxlength) ⇒ Object



23
24
25
26
# File 'app/models/alchemy/essence_spree_product.rb', line 23

def preview_text(_maxlength)
  return unless product
  product.name
end