Class: Effective::CartItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/cart_item.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



22
23
24
# File 'app/models/effective/cart_item.rb', line 22

def name
  purchasable&.purchasable_name
end

#priceObject



26
27
28
29
30
31
32
# File 'app/models/effective/cart_item.rb', line 26

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

#subtotalObject



38
39
40
# File 'app/models/effective/cart_item.rb', line 38

def subtotal
  price * quantity
end

#tax_exemptObject



34
35
36
# File 'app/models/effective/cart_item.rb', line 34

def tax_exempt
  purchasable&.tax_exempt || false
end

#to_sObject



18
19
20
# File 'app/models/effective/cart_item.rb', line 18

def to_s
  name || 'New Cart Item'
end