Sha256: a913ddd78b468971e027c5b7da9df7bcd916a0cd38003355f4e4be455871a0ef
Contents?: true
Size: 800 Bytes
Versions: 18
Compression:
Stored size: 800 Bytes
Contents
module Effective class CartItem < ActiveRecord::Base self.table_name = EffectiveOrders.cart_items_table_name.to_s belongs_to :cart, counter_cache: true, class_name: 'Effective::Cart' belongs_to :purchasable, polymorphic: true # Attributes # quantity :integer # timestamps validates :purchasable, presence: true validates :quantity, presence: true def price if (purchasable.price || 0).kind_of?(Integer) purchasable.price || 0 else raise 'expected price to be an Integer representing the number of cents.' end end def title purchasable.try(:title) || 'New Cart Item' end def tax_exempt purchasable.try(:tax_exempt) || false end def subtotal price * quantity end end end
Version data entries
18 entries across 18 versions & 1 rubygems