class Returnly::Services::MarkItemsAsReturned

Attributes

line_items[RW]
order[RW]

Public Class Methods

new(order, line_items) click to toggle source
# File lib/returnly/services/mark_items_as_returned.rb, line 6
def initialize(order, line_items)
  @order      = order
  @line_items = line_items
end

Public Instance Methods

perform!() click to toggle source
# File lib/returnly/services/mark_items_as_returned.rb, line 11
def perform!
  line_items.each do |line_item|
    quantity = line_item[:units].to_i
    inventory_units_by(line_item[:order_line_item_id]).take(quantity).each(&:return)
  end
end

Private Instance Methods

inventory_units_by(line_item_id) click to toggle source
# File lib/returnly/services/mark_items_as_returned.rb, line 20
def inventory_units_by(line_item_id)
  order.inventory_units.where(line_item_id: line_item_id)
end