Class: Yukon::Cart

Inherits:
Object
  • Object
show all
Defined in:
lib/yukon/cart.rb

Instance Method Summary collapse

Constructor Details

#initialize(product) ⇒ Cart

Returns a new instance of Cart.



4
5
6
# File 'lib/yukon/cart.rb', line 4

def initialize(product)
  @product = product
end

Instance Method Details

#contentsObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yukon/cart.rb', line 12

def contents
  {
    items:    [
      {
        name:         @product.name,
        amount:       @product.price_in_cents,
        quantity:     1,
        description:  "Digital product purchase"
      }
    ]
  }
end

#total_amountObject



8
9
10
# File 'lib/yukon/cart.rb', line 8

def total_amount
  contents[:items][0][:amount]
end