Class: SpreeCmCommissioner::OrderRejectedStateUpdater

Inherits:
BaseInteractor
  • Object
show all
Defined in:
app/interactors/spree_cm_commissioner/order_rejected_state_updater.rb

Instance Method Summary collapse

Instance Method Details

#callObject



6
7
8
9
10
11
# File 'app/interactors/spree_cm_commissioner/order_rejected_state_updater.rb', line 6

def call
  return context.fail!(message: 'error while update state') unless order.requested_state?

  update_request_state
  update_line_item_rejected_at_and_rejected_by
end

#update_line_item_rejected_at_and_rejected_byObject



17
18
19
20
21
# File 'app/interactors/spree_cm_commissioner/order_rejected_state_updater.rb', line 17

def update_line_item_rejected_at_and_rejected_by
  order.line_items.each do |line_item|
    line_item.rejected_by(authorized_user)
  end
end

#update_request_stateObject



13
14
15
# File 'app/interactors/spree_cm_commissioner/order_rejected_state_updater.rb', line 13

def update_request_state
  order.update(request_state: :rejected)
end