Class: Hola::Cart::Item::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/hola/cart/item/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_id:, quantity:) ⇒ Processor

Returns a new instance of Processor.



16
17
18
19
# File 'lib/hola/cart/item/processor.rb', line 16

def initialize(product_id:, quantity:)
  @product_id = product_id
  @quantity = quantity
end

Instance Attribute Details

#product_idObject (readonly)

Returns the value of attribute product_id.



14
15
16
# File 'lib/hola/cart/item/processor.rb', line 14

def product_id
  @product_id
end

#quantityObject (readonly)

Returns the value of attribute quantity.



14
15
16
# File 'lib/hola/cart/item/processor.rb', line 14

def quantity
  @quantity
end

Instance Method Details

#performObject



21
22
23
24
25
26
27
28
# File 'lib/hola/cart/item/processor.rb', line 21

def perform
  Cart::Item.new(
    product: product,
    quantity: quantity,
    subtotal: offer.subtotal,
    offer: (offer.name if offer.applied?)
  )
end