Class: Portage::Ucp::ReorderResult

Inherits:
Data
  • Object
show all
Defined in:
lib/portage/ucp/value_objects.rb

Overview

Portage extension — the hydrated Cart plus what got dropped along the way, so a caller can tell the buyer what to expect before checkout rather than silently under-filling the cart.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cart:, unavailable_items: []) ⇒ ReorderResult

Returns a new instance of ReorderResult.



537
# File 'lib/portage/ucp/value_objects.rb', line 537

def initialize(cart:, unavailable_items: []) = super

Instance Attribute Details

#cart ⇒ Object (readonly)

Returns the value of attribute cart

Returns:

  • (Object) —

    the current value of cart



536
537
538
# File 'lib/portage/ucp/value_objects.rb', line 536

def cart
  @cart
end

#unavailable_items ⇒ Object (readonly)

Returns the value of attribute unavailable_items

Returns:

  • (Object) —

    the current value of unavailable_items



536
537
538
# File 'lib/portage/ucp/value_objects.rb', line 536

def unavailable_items
  @unavailable_items
end

Instance Method Details

#to_wire_h ⇒ Object



539
540
541
542
543
# File 'lib/portage/ucp/value_objects.rb', line 539

def to_wire_h
  h = { "cart" => cart.to_wire_h }
  h["unavailable_items"] = unavailable_items.map(&:to_wire_h) unless unavailable_items.empty?
  h
end