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



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

def name
  purchasable&.purchasable_name
end

#priceObject



23
24
25
26
27
28
29
# File 'app/models/effective/cart_item.rb', line 23

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



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

def subtotal
  price * quantity
end

#tax_exemptObject



31
32
33
# File 'app/models/effective/cart_item.rb', line 31

def tax_exempt
  purchasable&.tax_exempt || false
end

#to_sObject



15
16
17
# File 'app/models/effective/cart_item.rb', line 15

def to_s
  name || 'New Cart Item'
end